Skip to content

Commit d5d2b8a

Browse files
chore: state updates for menu
1 parent 0cc68b5 commit d5d2b8a

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dist
3030
.report
3131
.agents
3232
docs/plans
33+
docs/superpowers
3334
CLAUDE.md
3435

3536
# debug

apps/showcase/demo/headless/contextmenu/basic-demo.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export default function BasicDemo() {
2222
const portal = usePortal();
2323

2424
usePositioner({
25-
anchor: contextmenu.popover?.state.anchorElement,
26-
content: contextmenu.popover?.state.positionerElement,
27-
arrow: contextmenu.popover?.state.arrowElement,
25+
anchor: contextmenu.state.anchorElement,
26+
content: contextmenu.state.positionerElement,
27+
arrow: contextmenu.state.arrowElement,
2828
sideOffset: 8,
2929
flip: true,
3030
shift: true,
@@ -33,8 +33,8 @@ export default function BasicDemo() {
3333
});
3434

3535
usePositioner({
36-
anchor: viewSub.menusub?.popover?.state.anchorElement,
37-
content: viewSub.menusub?.popover?.state.positionerElement,
36+
anchor: viewSub.menusub?.state.anchorElement,
37+
content: viewSub.menusub?.state.positionerElement,
3838
sideOffset: 0,
3939
flip: true,
4040
shift: true,

packages/@primereact/headless/src/menu/sub/useMenuSub.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ export const useMenuSub = withHeadless({
1919
}, []);
2020

2121
const state = {
22-
open: !!popover.state.open
22+
open: !!popover.state.open,
23+
anchorElement: popover.state.anchorElement,
24+
positionerElement: popover.state.positionerElement,
25+
popupElement: popover.state.popupElement,
26+
arrowElement: popover.state.arrowElement
2327
};
2428

2529
const toggle = () => {

packages/@primereact/headless/src/menu/useMenu.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ export const useMenu = withHeadless({
4242
const state = {
4343
open: !!popover.state.open,
4444
focused: focusedState,
45-
focusedOptionId
45+
focusedOptionId,
46+
anchorElement: popover.state.anchorElement,
47+
positionerElement: popover.state.positionerElement,
48+
popupElement: popover.state.popupElement,
49+
arrowElement: popover.state.arrowElement
4650
};
4751

4852
const getItemId = React.useCallback(
@@ -607,9 +611,7 @@ export const useMenu = withHeadless({
607611

608612
if (!element) return;
609613

610-
const level = getItemLevel(element);
611-
612-
onItemClick(event, props.composite ? false : level !== 0, !!popover.state.open);
614+
onItemClick(event, false, !!popover.state.open);
613615
}
614616

615617
event.preventDefault();

0 commit comments

Comments
 (0)