about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/components/icon_button.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-08-06 14:18:09 +0200
committerThibaut Girka <thib@sitedethib.com>2019-08-06 16:36:18 +0200
commitd10f6036cfeebec5b2c160db8659d2c19d29fe9c (patch)
tree696f5ae9a70891e96fdf819905b05aa6482bcf07 /app/javascript/flavours/glitch/components/icon_button.js
parent6d2b0fa3f0f32c874863e7fe035270dc31cdcc58 (diff)
Implement keyboard navigation in glitch-soc composer
Diffstat (limited to 'app/javascript/flavours/glitch/components/icon_button.js')
-rw-r--r--app/javascript/flavours/glitch/components/icon_button.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/components/icon_button.js b/app/javascript/flavours/glitch/components/icon_button.js
index c1e2f664c..521353238 100644
--- a/app/javascript/flavours/glitch/components/icon_button.js
+++ b/app/javascript/flavours/glitch/components/icon_button.js
@@ -13,6 +13,7 @@ export default class IconButton extends React.PureComponent {
     onClick: PropTypes.func,
     onMouseDown: PropTypes.func,
     onKeyDown: PropTypes.func,
+    onKeyPress: PropTypes.func,
     size: PropTypes.number,
     active: PropTypes.bool,
     pressed: PropTypes.bool,
@@ -45,6 +46,12 @@ export default class IconButton extends React.PureComponent {
     }
   }
 
+  handleKeyPress = (e) => {
+    if (this.props.onKeyPress && !this.props.disabled) {
+      this.props.onKeyPress(e);
+    }
+  }
+
   handleMouseDown = (e) => {
     if (!this.props.disabled && this.props.onMouseDown) {
       this.props.onMouseDown(e);
@@ -121,6 +128,7 @@ export default class IconButton extends React.PureComponent {
           onClick={this.handleClick}
           onMouseDown={this.handleMouseDown}
           onKeyDown={this.handleKeyDown}
+          onKeyPress={this.handleKeyPress}
           style={style}
           tabIndex={tabIndex}
           disabled={disabled}
@@ -142,6 +150,7 @@ export default class IconButton extends React.PureComponent {
             onClick={this.handleClick}
             onMouseDown={this.handleMouseDown}
             onKeyDown={this.handleKeyDown}
+            onKeyPress={this.handleKeyPress}
             style={style}
             tabIndex={tabIndex}
             disabled={disabled}