Replace react-overlays with Floating UI (#39621)
This commit is contained in:
1 parent
41982dac45
commit
296750204a
27 files changed
+587
-528
No files matched your search
@@ -52,14 +52,6 @@ export const BoostModal: React.FC<{
|
||||
onClose();
|
||||
}, [onClose]);
|
||||
|
||||
const findContainer = useCallback(
|
||||
() =>
|
||||
document.getElementsByClassName(
|
||||
'modal-root__container',
|
||||
)[0] as HTMLDivElement,
|
||||
[],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='modal-root__modal safety-action-modal'>
|
||||
<div className='safety-action-modal__top'>
|
||||
@@ -109,7 +101,6 @@ export const BoostModal: React.FC<{
|
||||
<PrivacyDropdown
|
||||
noDirect
|
||||
value={privacy}
|
||||
container={findContainer}
|
||||
onChange={onPrivacyChange}
|
||||
disabled={statusVisibility === 'private'}
|
||||
/>
|
||||
|
||||
@@ -4,13 +4,8 @@ import { useIntl, defineMessages } from 'react-intl';
|
||||
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
import type {
|
||||
OffsetValue,
|
||||
UsePopperOptions,
|
||||
} from 'react-overlays/esm/usePopper';
|
||||
import Overlay from 'react-overlays/Overlay';
|
||||
|
||||
import { DropdownMenu } from 'mastodon/components/dropdown_menu';
|
||||
import { Popover } from 'mastodon/components/popover';
|
||||
import { useIdentity } from 'mastodon/identity_context';
|
||||
import type { MenuItem } from 'mastodon/models/dropdown_menu';
|
||||
import { useAppSelector } from 'mastodon/store';
|
||||
@@ -27,9 +22,6 @@ const messages = defineMessages({
|
||||
muteHashtag: { id: 'hashtag.mute', defaultMessage: 'Mute #{hashtag}' },
|
||||
});
|
||||
|
||||
const offset = [5, 5] as OffsetValue;
|
||||
const popperConfig = { strategy: 'fixed' } as UsePopperOptions;
|
||||
|
||||
const isHashtagLink = (
|
||||
element: HTMLAnchorElement | null,
|
||||
): element is HTMLAnchorElement => {
|
||||
@@ -135,30 +127,19 @@ export const HashtagMenuController: React.FC = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<Overlay
|
||||
show={open}
|
||||
offset={offset}
|
||||
placement='bottom'
|
||||
flip
|
||||
target={element}
|
||||
popperConfig={popperConfig}
|
||||
>
|
||||
{({ props, arrowProps, placement }) => (
|
||||
<div {...props}>
|
||||
<div className={`dropdown-animation dropdown-menu ${placement}`}>
|
||||
<div
|
||||
className={`dropdown-menu__arrow ${placement}`}
|
||||
{...arrowProps}
|
||||
/>
|
||||
|
||||
<DropdownMenu
|
||||
items={menu}
|
||||
onClose={handleClose}
|
||||
openedViaKeyboard={false}
|
||||
/>
|
||||
</div>
|
||||
<Popover isOpen={open} offset={5} reference={element} onClose={handleClose}>
|
||||
{({ props, placement }) => (
|
||||
<div
|
||||
{...props}
|
||||
className={`dropdown-animation dropdown-menu ${placement}`}
|
||||
>
|
||||
<DropdownMenu
|
||||
items={menu}
|
||||
onClose={handleClose}
|
||||
openedViaKeyboard={false}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Overlay>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user