fix(giphy-integration) Fix input issues (#11601)

Fix auto focus on menu open
Fix unable to use space in input
This commit is contained in:
Robert Pintilii 2022-05-31 09:58:25 +01:00 committed by GitHub
parent 5cef3dc1ba
commit de294cae92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 3 deletions

View File

@ -2,7 +2,6 @@
import React, { PureComponent } from 'react';
import { isMobileBrowser } from '../../../environment/utils';
import { getFieldValue } from '../../../react';
type Props = {
@ -131,11 +130,16 @@ export default class InputField extends PureComponent<Props, State> {
onChange = { this._onChange }
onFocus = { this._onFocus }
onKeyDown = { this._onKeyDown }
onKeyPress = { this._onKeyPress }
placeholder = { this.props.placeHolder }
readOnly = { this.props.readOnly }
// eslint-disable-next-line react/jsx-no-bind
ref = { inputElement => this.props.autoFocus && isMobileBrowser()
&& inputElement && inputElement.focus() }
ref = { inputElement => {
if (this.props.autoFocus) {
inputElement && inputElement.focus();
setTimeout(() => inputElement && inputElement.focus(), 200);
}
} }
type = { this.props.type }
value = { this.state.value } />
);
@ -200,4 +204,14 @@ export default class InputField extends PureComponent<Props, State> {
onSubmit && event.key === 'Enter' && onSubmit();
}
/**
* Stop event propagation on key press.
*
* @param {Event} event - Key press event object.
* @returns {void}
*/
_onKeyPress(event) {
event.stopPropagation();
}
}