Skip to content

Commit 6d2a3ab

Browse files
committed
Fix menu opening in table with summary
1 parent 809ea73 commit 6d2a3ab

File tree

2 files changed

+32
-27
lines changed

2 files changed

+32
-27
lines changed

assets/packs/data_table/App.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export function App({ ctx, data }) {
119119
const [columns, setColumns] = useState(columnsInitData);
120120
const [colSizes, setColSizes] = useState(columnsInitSize);
121121
const [menu, setMenu] = useState(null);
122+
const [showMenu, setShowMenu] = useState(false);
122123
const [selection, setSelection] = useState(emptySelection);
123124
const [rowMarkerOffset, setRowMarkerOffset] = useState(0);
124125
const [hoverRows, setHoverRows] = useState(null);
@@ -324,7 +325,7 @@ export function App({ ctx, data }) {
324325
};
325326

326327
const { layerProps, renderLayer } = useLayer({
327-
isOpen: !!menu,
328+
isOpen: showMenu,
328329
auto: true,
329330
placement: "bottom-end",
330331
possiblePlacements: ["bottom-end", "bottom-center", "bottom-start"],
@@ -440,6 +441,10 @@ export function App({ ctx, data }) {
440441
themeOverride: header.id === currentMenu ? themeOverride : null,
441442
}));
442443
setColumns(newColumns);
444+
// We determine showMenu in the useEffect, so it is deferred to
445+
// the next render cycle, otherwise the menu closes immediately
446+
// in onOutsideClick. See the discussion in https://github.com/livebook-dev/kino/pull/213#discussion_r1033043059
447+
setShowMenu(menu ? true : false);
443448
}, [menu]);
444449

445450
return (
@@ -511,7 +516,7 @@ export function App({ ctx, data }) {
511516
onColumnMoved={hasRelocate ? onColumnMoved : undefined}
512517
/>
513518
)}
514-
{menu &&
519+
{showMenu &&
515520
renderLayer(
516521
<HeaderMenu
517522
layerProps={layerProps}

lib/assets/data_table/build/main.js

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)