diff --git a/src/smart-components/App/stories/index.stories.js b/src/smart-components/App/stories/index.stories.js index 8f0667f5e..643ffe04d 100644 --- a/src/smart-components/App/stories/index.stories.js +++ b/src/smart-components/App/stories/index.stories.js @@ -376,6 +376,24 @@ const CustomApp = () => { export const customer1 = () => fitPageSize(); +export const customer2 = () => ( +
+
+ +
+
+); + export const disableUserProfile = () => fitPageSize( { if (messages) { // https://github.com/scabbiaza/react-scroll-position-on-updating-dom + // Set block to nearest to prevent unexpected scrolling from outer components try { - first.scrollIntoView(); + first.scrollIntoView({ block: 'nearest' }); } catch (error) { // } @@ -71,7 +72,7 @@ export default class ConversationScroll extends Component { if (messages) { // https://github.com/scabbiaza/react-scroll-position-on-updating-dom try { - last.scrollIntoView(); + last.scrollIntoView({ block: 'nearest' }); } catch (error) { // } diff --git a/src/ui/ContextMenu/index.scss b/src/ui/ContextMenu/index.scss index eb7581bb0..0a35588af 100644 --- a/src/ui/ContextMenu/index.scss +++ b/src/ui/ContextMenu/index.scss @@ -1,5 +1,10 @@ @import '../../styles/variables'; +body.sendbird-emoji-list-pop-up, +body.sendbird-menu-items-pop-up { + overflow: hidden !important; +} + .sendbird__offline { .sendbird-dropdown__menu .sendbird-dropdown__menu-item { cursor: not-allowed; diff --git a/src/ui/ContextMenu/items/EmojiListItems.jsx b/src/ui/ContextMenu/items/EmojiListItems.jsx index 3c6d80777..cc16c9506 100644 --- a/src/ui/ContextMenu/items/EmojiListItems.jsx +++ b/src/ui/ContextMenu/items/EmojiListItems.jsx @@ -4,10 +4,13 @@ import PropTypes from 'prop-types'; import SortByRow from '../../SortByRow'; +const EMOJI_LIST_POP_UP = 'sendbird-emoji-list-pop-up'; + export default class EmojiListItems extends Component { constructor(props) { super(props); this.reactionRef = React.createRef(); + this.rootForPopup = document.body; this.state = { reactionStyle: {}, handleClickOutside: () => { }, @@ -18,11 +21,15 @@ export default class EmojiListItems extends Component { this.setupEvents(); this.getBarPosition(); this.showParent(); + // add className to body + this.rootForPopup.className = `${EMOJI_LIST_POP_UP} ${this.rootForPopup.className}`; } componentWillUnmount() { this.cleanUpEvents(); this.hideParent(); + // remove className from body + this.rootForPopup.className = this.rootForPopup.className.split(' ').filter((className) => className !== EMOJI_LIST_POP_UP).join(' '); } showParent = () => { diff --git a/src/ui/ContextMenu/items/MenuItems.jsx b/src/ui/ContextMenu/items/MenuItems.jsx index c68ee1f75..1828666cb 100644 --- a/src/ui/ContextMenu/items/MenuItems.jsx +++ b/src/ui/ContextMenu/items/MenuItems.jsx @@ -2,10 +2,13 @@ import React, { Component } from 'react'; import { createPortal } from 'react-dom'; import PropTypes from 'prop-types'; +const MENU_ITEMS_POP_UP = 'sendbird-menu-items-pop-up'; + export default class MenuItems extends Component { constructor(props) { super(props); this.menuRef = React.createRef(); + this.rootForPopup = document.body; this.state = { menuStyle: {}, handleClickOutside: () => { }, @@ -16,11 +19,15 @@ export default class MenuItems extends Component { this.setupEvents(); this.getMenuPosition(); this.showParent(); + // add className to body + this.rootForPopup.className = `${MENU_ITEMS_POP_UP} ${this.rootForPopup.className}`; } componentWillUnmount() { this.cleanUpEvents(); this.hideParent(); + // remove className from body + this.rootForPopup.className = this.rootForPopup.className.split(' ').filter((className) => className !== MENU_ITEMS_POP_UP).join(' '); } showParent = () => { diff --git a/src/ui/Modal/index.jsx b/src/ui/Modal/index.jsx index f9e7b7461..2b43e2998 100644 --- a/src/ui/Modal/index.jsx +++ b/src/ui/Modal/index.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import React, { useContext, useEffect } from 'react'; import PropTypes from 'prop-types'; import { createPortal } from 'react-dom'; @@ -80,6 +80,14 @@ export default function Modal(props) { hideFooter, type, } = props; + const { body } = document; + useEffect(() => { + body.className = `sendbird-modal-pop-up ${body.className}`; + return () => { + body.className = body.className.split(' ').filter((className) => className !== 'sendbird-modal-pop-up').join(' '); + }; + }, []); + return createPortal((
diff --git a/src/ui/Modal/index.scss b/src/ui/Modal/index.scss index b973475be..b9c355ae3 100644 --- a/src/ui/Modal/index.scss +++ b/src/ui/Modal/index.scss @@ -61,3 +61,7 @@ background-color: t(overlay-2); } } + +body.sendbird-modal-pop-up { + overflow: hidden !important; +}