diff --git a/components/button/i18n/en.pot b/components/button/i18n/en.pot new file mode 100644 index 0000000000..64cc7e89f6 --- /dev/null +++ b/components/button/i18n/en.pot @@ -0,0 +1,12 @@ +msgid "" +msgstr "" +"Project-Id-Version: i18next-conv\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"POT-Creation-Date: 2024-06-03T15:53:41.329Z\n" +"PO-Revision-Date: 2024-06-03T15:53:41.329Z\n" + +msgid "Toggle dropdown" +msgstr "Toggle dropdown" diff --git a/components/button/src/split-button/split-button.js b/components/button/src/split-button/split-button.js index afefeffbec..acde0d69ae 100644 --- a/components/button/src/split-button/split-button.js +++ b/components/button/src/split-button/split-button.js @@ -29,6 +29,7 @@ class SplitButton extends Component { componentWillUnmount() { document.removeEventListener('keydown', this.handleKeyDown) } + handleKeyDown = (event) => { if (event.key === 'Escape' && this.state.open) { event.preventDefault() @@ -38,6 +39,27 @@ class SplitButton extends Component { } } + handleButtonKeyDown = (event) => { + if (event.key === 'Enter') { + event.preventDefault() + this.onClick( + { + name: this.props.name, + value: this.props.value, + open: this.state.open, + }, + event + ) + } + } + + handleToggleKeyDown = (event) => { + if (event.key === 'Enter' || event.key === ' ') { + event.preventDefault() + this.onToggle() + } + } + onClick = (payload, event) => { if (this.props.onClick) { this.props.onClick( @@ -96,6 +118,7 @@ class SplitButton extends Component { className={cx(className)} initialFocus={initialFocus} dataTest={`${dataTest}-button`} + onKeyDown={this.handleButtonKeyDown} > {children} @@ -116,6 +139,7 @@ class SplitButton extends Component { dataTest={`${dataTest}-toggle`} title={i18n.t('Toggle dropdown')} aria-label={i18n.t('Toggle dropdown')} + onKeyDown={this.handleToggleKeyDown} > {arrow}