File tree Expand file tree Collapse file tree 2 files changed +36
-25
lines changed
Expand file tree Collapse file tree 2 files changed +36
-25
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ $block: '.#{$ns}navigation-popup';
1010 margin-top : $offset ;
1111
1212 @include navigation-popup ();
13+ @include text-size (body- 2);
1314
1415 & __list {
1516 @include reset-list-style ();
Original file line number Diff line number Diff line change @@ -16,30 +16,40 @@ export const NavigationPopup: React.FC<NavigationPopupProps> = ({
1616 items,
1717 onClose,
1818 open,
19- } ) => (
20- < Popup
21- // Workaround to recalculate position on every opening. Required for valid position calculation for scrolled header links.
22- anchorRef = { open ? anchorRef : undefined }
23- open = { open }
24- onClose = { onClose }
25- onOutsideClick = { onClose }
26- keepMounted
27- disablePortal
28- strategy = "fixed"
29- placement = "bottom-start"
30- offset = { OFFSET_RESET }
31- >
32- < ul className = { b ( 'list' ) } >
33- { items . map ( ( item ) => (
34- < NavigationItem
35- key = { item . text }
36- className = { b ( 'link' ) }
37- data = { item }
38- menuLayout = { NavigationLayout . Dropdown }
39- />
40- ) ) }
41- </ ul >
42- </ Popup >
43- ) ;
19+ } ) => {
20+ // Opening and closing is controlled by the associated button,
21+ // but in order to give the popup control over closing as well (e.g. on click outside or escape key press)
22+ // there needs to be an awkward looking handler like this.
23+ const onOpenChange = ( isOpen : boolean ) => {
24+ if ( ! isOpen ) {
25+ onClose ( ) ;
26+ }
27+ } ;
28+
29+ return (
30+ < Popup
31+ className = { b ( ) }
32+ // Workaround to recalculate position on every opening. Required for valid position calculation for scrolled header links.
33+ anchorElement = { anchorRef . current }
34+ open = { open }
35+ onOpenChange = { onOpenChange }
36+ keepMounted
37+ strategy = "fixed"
38+ placement = "bottom-start"
39+ offset = { OFFSET_RESET }
40+ >
41+ < ul className = { b ( 'list' ) } >
42+ { items . map ( ( item ) => (
43+ < NavigationItem
44+ key = { item . text }
45+ className = { b ( 'link' ) }
46+ data = { item }
47+ menuLayout = { NavigationLayout . Dropdown }
48+ />
49+ ) ) }
50+ </ ul >
51+ </ Popup >
52+ ) ;
53+ } ;
4454
4555export default NavigationPopup ;
You can’t perform that action at this time.
0 commit comments