[MM-56607] Upgrade to "@floating-ui/react" for acknowledgements/post_acknowledgements component (#25979)

Этот коммит содержится в:
M-ZubairAhmed
2024-01-24 04:30:13 +00:00
коммит произвёл GitHub
родитель df79ebed79
Коммит 686b22a076
2 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@@ -18,6 +18,7 @@ type OwnProps = {
function makeMapStateToProps() { function makeMapStateToProps() {
const getPostAcknowledgementsWithProfiles = makeGetPostAcknowledgementsWithProfiles(); const getPostAcknowledgementsWithProfiles = makeGetPostAcknowledgementsWithProfiles();
return (state: GlobalState, ownProps: OwnProps) => { return (state: GlobalState, ownProps: OwnProps) => {
const currentUserId = getCurrentUserId(state); const currentUserId = getCurrentUserId(state);
const hasReactions = getHasReactions(state, ownProps.postId); const hasReactions = getHasReactions(state, ownProps.postId);

Просмотреть файл

@@ -13,7 +13,7 @@ import {
useId, useId,
useInteractions, useInteractions,
useRole, useRole,
} from '@floating-ui/react-dom-interactions'; } from '@floating-ui/react';
import classNames from 'classnames'; import classNames from 'classnames';
import React, {memo, useState} from 'react'; import React, {memo, useState} from 'react';
import {FormattedMessage} from 'react-intl'; import {FormattedMessage} from 'react-intl';
@@ -67,7 +67,7 @@ function PostAcknowledgements({
} }
const buttonDisabled = (Boolean(acknowledgedAt) && moreThan5minAgo(acknowledgedAt)) || isCurrentAuthor; const buttonDisabled = (Boolean(acknowledgedAt) && moreThan5minAgo(acknowledgedAt)) || isCurrentAuthor;
const {x, y, reference, floating, strategy, context} = useFloating({ const {x, y, strategy, context, refs: {setReference, setFloating}} = useFloating({
open, open,
onOpenChange: setOpen, onOpenChange: setOpen,
placement: 'top-start', placement: 'top-start',
@@ -92,9 +92,9 @@ function PostAcknowledgements({
open: 300, open: 300,
close: 0, close: 0,
}, },
restMs: 100,
handleClose: safePolygon({ handleClose: safePolygon({
blockPointerEvents: false, blockPointerEvents: false,
restMs: 100,
}), }),
}), }),
useRole(context), useRole(context),
@@ -131,7 +131,7 @@ function PostAcknowledgements({
const button = ( const button = (
<> <>
<button <button
ref={reference} ref={setReference}
onClick={handleClick} onClick={handleClick}
className={classNames({ className={classNames({
AcknowledgementButton: true, AcknowledgementButton: true,
@@ -161,7 +161,7 @@ function PostAcknowledgements({
modal={false} modal={false}
> >
<div <div
ref={floating} ref={setFloating}
style={{ style={{
position: strategy, position: strategy,
top: y ?? 0, top: y ?? 0,