Fix emoji reaction popup position
This commit is contained in:
parent
5c786b4868
commit
bcb6f80ac3
@ -327,6 +327,7 @@ class EmojiPickerDropdown extends PureComponent {
|
|||||||
state = {
|
state = {
|
||||||
active: false,
|
active: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
bottom: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
setRef = (c) => {
|
setRef = (c) => {
|
||||||
@ -334,6 +335,7 @@ class EmojiPickerDropdown extends PureComponent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onShowDropdown = () => {
|
onShowDropdown = () => {
|
||||||
|
this.updateDropdownPosition();
|
||||||
this.setState({ active: true });
|
this.setState({ active: true });
|
||||||
|
|
||||||
if (!EmojiPicker) {
|
if (!EmojiPicker) {
|
||||||
@ -354,6 +356,23 @@ class EmojiPickerDropdown extends PureComponent {
|
|||||||
this.setState({ active: false });
|
this.setState({ active: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateDropdownPosition = () => {
|
||||||
|
let bottom = true;
|
||||||
|
|
||||||
|
if (this.target) {
|
||||||
|
const height = window.innerHeight;
|
||||||
|
const rect = this.target.getBoundingClientRect();
|
||||||
|
|
||||||
|
if (height && rect) {
|
||||||
|
bottom = height / 2 > rect.top;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.bottom !== bottom) {
|
||||||
|
this.setState({ bottom });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onToggle = (e) => {
|
onToggle = (e) => {
|
||||||
if (!this.state.loading && (!e.key || e.key === 'Enter')) {
|
if (!this.state.loading && (!e.key || e.key === 'Enter')) {
|
||||||
if (this.state.active) {
|
if (this.state.active) {
|
||||||
@ -381,7 +400,7 @@ class EmojiPickerDropdown extends PureComponent {
|
|||||||
render () {
|
render () {
|
||||||
const { intl, onPickEmoji, onSkinTone, skinTone, frequentlyUsedEmojis, button } = this.props;
|
const { intl, onPickEmoji, onSkinTone, skinTone, frequentlyUsedEmojis, button } = this.props;
|
||||||
const title = intl.formatMessage(messages.emoji);
|
const title = intl.formatMessage(messages.emoji);
|
||||||
const { active, loading } = this.state;
|
const { active, loading, bottom } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='emoji-picker-dropdown' onKeyDown={this.handleKeyDown}>
|
<div className='emoji-picker-dropdown' onKeyDown={this.handleKeyDown}>
|
||||||
@ -393,7 +412,7 @@ class EmojiPickerDropdown extends PureComponent {
|
|||||||
/>}
|
/>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Overlay show={active} placement={'bottom'} target={this.findTarget} popperConfig={{ strategy: 'fixed' }}>
|
<Overlay show={active} placement={ bottom ? 'bottom' : 'top' } target={this.findTarget} popperConfig={{ strategy: 'fixed' }}>
|
||||||
{({ props, placement })=> (
|
{({ props, placement })=> (
|
||||||
<div {...props} style={{ ...props.style, width: 299 }}>
|
<div {...props} style={{ ...props.style, width: 299 }}>
|
||||||
<div className={`dropdown-animation ${placement}`}>
|
<div className={`dropdown-animation ${placement}`}>
|
||||||
|
Loading…
Reference in New Issue
Block a user