pass getClickableArea into autosuggesttextarea as prop
This commit is contained in:
parent
0b7763e726
commit
99f0a069dd
2 changed files with 3 additions and 6 deletions
|
@ -51,6 +51,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
|
||||||
onFocus: PropTypes.func,
|
onFocus: PropTypes.func,
|
||||||
onBlur: PropTypes.func,
|
onBlur: PropTypes.func,
|
||||||
clickableAreaRef: PropTypes.object,
|
clickableAreaRef: PropTypes.object,
|
||||||
|
getClickableArea: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
|
@ -164,14 +165,9 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
|
||||||
this.textarea.focus();
|
this.textarea.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
getClickableArea = () => {
|
|
||||||
const { clickableAreaRef } = this.props;
|
|
||||||
return clickableAreaRef ? clickableAreaRef.current : this.form;
|
|
||||||
}
|
|
||||||
|
|
||||||
isClickInside = (e) => {
|
isClickInside = (e) => {
|
||||||
return [
|
return [
|
||||||
this.getClickableArea(),
|
this.props.getClickableArea(),
|
||||||
document.querySelector('.autosuggest-textarea__textarea'),
|
document.querySelector('.autosuggest-textarea__textarea'),
|
||||||
].some(element => element && element.contains(e.target));
|
].some(element => element && element.contains(e.target));
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,6 +286,7 @@ class ComposeForm extends ImmutablePureComponent {
|
||||||
onSuggestionSelected={this.onSuggestionSelected}
|
onSuggestionSelected={this.onSuggestionSelected}
|
||||||
onPaste={onPaste}
|
onPaste={onPaste}
|
||||||
autoFocus={shouldAutoFocus}
|
autoFocus={shouldAutoFocus}
|
||||||
|
getClickableArea={this.getClickableArea}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
!condensed &&
|
!condensed &&
|
||||||
|
|
Loading…
Reference in a new issue