static defaultProps = {
style: {},
loading: true,
- placement: 'bottom',
frequentlyUsedEmojis: [],
};
state = {
modifierOpen: false,
+ placement: null,
};
handleDocumentClick = e => {
this.dropdown = c;
}
- onShowDropdown = () => {
+ onShowDropdown = ({ target }) => {
this.setState({ active: true });
if (!EmojiPicker) {
this.setState({ loading: false });
});
}
+
+ const { top } = target.getBoundingClientRect();
+ this.setState({ placement: top * 2 < innerHeight ? 'bottom' : 'top' });
}
onHideDropdown = () => {
if (this.state.active) {
this.onHideDropdown();
} else {
- this.onShowDropdown();
+ this.onShowDropdown(e);
}
}
}
render () {
const { intl, onPickEmoji, onSkinTone, skinTone, frequentlyUsedEmojis } = this.props;
const title = intl.formatMessage(messages.emoji);
- const { active, loading } = this.state;
+ const { active, loading, placement } = this.state;
return (
<div className='emoji-picker-dropdown' onKeyDown={this.handleKeyDown}>
/>
</div>
- <Overlay show={active} placement='bottom' target={this.findTarget}>
+ <Overlay show={active} placement={placement} target={this.findTarget}>
<EmojiPickerMenu
custom_emojis={this.props.custom_emojis}
loading={loading}