diff options
author | Thibaut Girka <thib@sitedethib.com> | 2020-04-25 15:19:32 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2020-04-25 15:19:32 +0200 |
commit | 8b2823b7b6e5120ef8830db49e1e19927867ce14 (patch) | |
tree | 0e94a8cca8257fe9c60d5548d03ff915b6fa6729 /app/javascript/mastodon/features/compose | |
parent | 60f8a63a76f7c866b5338c33a8b897ba022368ca (diff) | |
parent | be637146f310d7ec3a49d01e850959514e9e4964 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Diffstat (limited to 'app/javascript/mastodon/features/compose')
-rw-r--r-- | app/javascript/mastodon/features/compose/components/privacy_dropdown.js | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/app/javascript/mastodon/features/compose/components/privacy_dropdown.js b/app/javascript/mastodon/features/compose/components/privacy_dropdown.js index de030b7a2..57588fe96 100644 --- a/app/javascript/mastodon/features/compose/components/privacy_dropdown.js +++ b/app/javascript/mastodon/features/compose/components/privacy_dropdown.js @@ -50,7 +50,7 @@ class PrivacyDropdownMenu extends React.PureComponent { const index = items.findIndex(item => { return (item.value === value); }); - let element; + let element = null; switch(e.key) { case 'Escape': @@ -60,18 +60,10 @@ class PrivacyDropdownMenu extends React.PureComponent { this.handleClick(e); break; case 'ArrowDown': - element = this.node.childNodes[index + 1]; - if (element) { - element.focus(); - this.props.onChange(element.getAttribute('data-index')); - } + element = this.node.childNodes[index + 1] || this.node.firstChild; break; case 'ArrowUp': - element = this.node.childNodes[index - 1]; - if (element) { - element.focus(); - this.props.onChange(element.getAttribute('data-index')); - } + element = this.node.childNodes[index - 1] || this.node.lastChild; break; case 'Tab': if (e.shiftKey) { @@ -79,28 +71,21 @@ class PrivacyDropdownMenu extends React.PureComponent { } else { element = this.node.childNodes[index + 1] || this.node.firstChild; } - if (element) { - element.focus(); - this.props.onChange(element.getAttribute('data-index')); - e.preventDefault(); - e.stopPropagation(); - } break; case 'Home': element = this.node.firstChild; - if (element) { - element.focus(); - this.props.onChange(element.getAttribute('data-index')); - } break; case 'End': element = this.node.lastChild; - if (element) { - element.focus(); - this.props.onChange(element.getAttribute('data-index')); - } break; } + + if (element) { + element.focus(); + this.props.onChange(element.getAttribute('data-index')); + e.preventDefault(); + e.stopPropagation(); + } } handleClick = e => { |