Skip to content

Commit 82d1e84

Browse files
committed
chore: test to see if this makes a difference
1 parent f4af399 commit 82d1e84

File tree

1 file changed

+15
-29
lines changed
  • polaris-react/src/components/ActionMenu/components/Actions/components/ActionsMeasurer

1 file changed

+15
-29
lines changed

polaris-react/src/components/ActionMenu/components/Actions/components/ActionsMeasurer/ActionsMeasurer.tsx

+15-29
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type {
44
MenuActionDescriptor,
55
MenuGroupDescriptor,
66
} from '../../../../../../types';
7-
import {useComponentDidMount} from '../../../../../../utilities/use-component-did-mount';
87
import {useI18n} from '../../../../../../utilities/i18n';
98
import {SecondaryAction} from '../../../SecondaryAction';
109
import {useEventListener} from '../../../../../../utilities/use-event-listener';
@@ -33,7 +32,6 @@ export function ActionsMeasurer({
3332
}: ActionsMeasurerProps) {
3433
const i18n = useI18n();
3534
const containerNode = useRef<HTMLDivElement>(null);
36-
const animationFrame = useRef<number | null>(null);
3735

3836
const defaultRollupGroup: MenuGroupDescriptor = {
3937
title: i18n.translate('Polaris.ActionMenu.Actions.moreActions'),
@@ -45,42 +43,30 @@ export function ActionsMeasurer({
4543
);
4644

4745
const handleMeasurement = useCallback(() => {
48-
if (animationFrame.current) {
49-
cancelAnimationFrame(animationFrame.current);
46+
if (!containerNode.current) {
47+
return;
5048
}
5149

52-
animationFrame.current = requestAnimationFrame(() => {
53-
if (!containerNode.current) {
54-
return;
55-
}
56-
57-
const containerWidth = containerNode.current.offsetWidth;
58-
const hiddenActionNodes = containerNode.current.children;
59-
const hiddenActionNodesArray = Array.from(hiddenActionNodes);
60-
const hiddenActionsWidths = hiddenActionNodesArray.map((node) => {
61-
const buttonWidth = Math.ceil(node.getBoundingClientRect().width);
62-
return buttonWidth + ACTION_SPACING;
63-
});
64-
const disclosureWidth = hiddenActionsWidths.pop() || 0;
65-
66-
handleMeasurementProp({
67-
containerWidth,
68-
disclosureWidth,
69-
hiddenActionsWidths,
70-
});
50+
const containerWidth = containerNode.current.offsetWidth;
51+
const hiddenActionNodes = containerNode.current.children;
52+
const hiddenActionNodesArray = Array.from(hiddenActionNodes);
53+
const hiddenActionsWidths = hiddenActionNodesArray.map((node) => {
54+
const buttonWidth = Math.ceil(node.getBoundingClientRect().width);
55+
return buttonWidth + ACTION_SPACING;
56+
});
57+
const disclosureWidth = hiddenActionsWidths.pop() || 0;
58+
59+
handleMeasurementProp({
60+
containerWidth,
61+
disclosureWidth,
62+
hiddenActionsWidths,
7163
});
7264
}, [handleMeasurementProp]);
7365

7466
useEffect(() => {
7567
handleMeasurement();
7668
}, [handleMeasurement, actions, groups]);
7769

78-
useComponentDidMount(() => {
79-
if (process.env.NODE_ENV === 'development') {
80-
setTimeout(handleMeasurement, 0);
81-
}
82-
});
83-
8470
const actionsMarkup = actions.map((action) => {
8571
const {content, onAction, ...rest} = action;
8672

0 commit comments

Comments
 (0)