Skip to content

Commit

Permalink
Reduce dom checks for toolbar (#5386)
Browse files Browse the repository at this point in the history
  • Loading branch information
snowystinger authored Nov 8, 2023
1 parent 3b4fb99 commit 2d5119f
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions packages/@react-aria/actiongroup/src/useActionGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ export function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListSta
} = props;

let [isInToolbar, setInToolbar] = useState(false);
// should be safe because re-calling set state with the same value it already has is a no-op
// this will allow us to react should a parent re-render and change its role though
// eslint-disable-next-line react-hooks/exhaustive-deps
useLayoutEffect(() => {
setInToolbar(!!(ref.current && ref.current.parentElement?.closest('[role="toolbar"]')));
});
}, [ref]);

let allKeys = [...state.collection.getKeys()];
if (!allKeys.some(key => !state.disabledKeys.has(key))) {
Expand Down

1 comment on commit 2d5119f

@rspbot
Copy link

@rspbot rspbot commented on 2d5119f Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.