]> cat aescling's git repositories - mastodon.git/commitdiff
Additional key checks for browser compatibility (#2539)
authorNoëlle Anthony <noelle.d.anthony@gmail.com>
Sun, 30 Apr 2017 13:12:14 +0000 (09:12 -0400)
committerMatt Jankowski <mjankowski@thoughtbot.com>
Sun, 30 Apr 2017 13:12:14 +0000 (09:12 -0400)
Not all browsers recognize e.key === 'Escape'; some use 'Esc' and some only respond to the keyCode.

app/assets/javascripts/components/features/ui/components/modal_root.jsx

index cfaa8a598830f78a141927b1adafaf040f9a2165..23057715cee143f1a5bf07f920af8b44c8ce6f8b 100644 (file)
@@ -22,7 +22,8 @@ class ModalRoot extends React.PureComponent {
   }
 
   handleKeyUp (e) {
-    if (e.key === 'Escape' && !!this.props.type) {
+    if ((e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27)
+         && !!this.props.type) {
       this.props.onClose();
     }
   }