Focus the UI when pressing Escape in the CW field
This commit is contained in:
parent
a8e896af12
commit
1cb7fe932d
1 changed files with 9 additions and 1 deletions
|
@ -43,6 +43,13 @@ const handlers = {
|
||||||
handleRefSpoilerText (spoilerText) {
|
handleRefSpoilerText (spoilerText) {
|
||||||
this.spoilerText = spoilerText;
|
this.spoilerText = spoilerText;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// When the escape key is released, we focus the UI.
|
||||||
|
handleKeyUp ({ key }) {
|
||||||
|
if (key === 'Escape') {
|
||||||
|
document.querySelector('.ui').parentElement.focus();
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// The component.
|
// The component.
|
||||||
|
@ -56,7 +63,7 @@ export default class ComposerSpoiler extends React.PureComponent {
|
||||||
|
|
||||||
// Rendering.
|
// Rendering.
|
||||||
render () {
|
render () {
|
||||||
const { handleKeyDown, handleRefSpoilerText } = this.handlers;
|
const { handleKeyDown, handleKeyUp, handleRefSpoilerText } = this.handlers;
|
||||||
const {
|
const {
|
||||||
hidden,
|
hidden,
|
||||||
intl,
|
intl,
|
||||||
|
@ -75,6 +82,7 @@ export default class ComposerSpoiler extends React.PureComponent {
|
||||||
id='glitch.composer.spoiler.input'
|
id='glitch.composer.spoiler.input'
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
|
onKeyUp={handleKeyUp}
|
||||||
placeholder={intl.formatMessage(messages.placeholder)}
|
placeholder={intl.formatMessage(messages.placeholder)}
|
||||||
type='text'
|
type='text'
|
||||||
value={text}
|
value={text}
|
||||||
|
|
Loading…
Reference in a new issue