Skip to content

Commit

Permalink
Fix menu opening in table with summary
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Mar 5, 2025
1 parent 809ea73 commit 6d2a3ab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
9 changes: 7 additions & 2 deletions assets/packs/data_table/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export function App({ ctx, data }) {
const [columns, setColumns] = useState(columnsInitData);
const [colSizes, setColSizes] = useState(columnsInitSize);
const [menu, setMenu] = useState(null);
const [showMenu, setShowMenu] = useState(false);
const [selection, setSelection] = useState(emptySelection);
const [rowMarkerOffset, setRowMarkerOffset] = useState(0);
const [hoverRows, setHoverRows] = useState(null);
Expand Down Expand Up @@ -324,7 +325,7 @@ export function App({ ctx, data }) {
};

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

return (
Expand Down Expand Up @@ -511,7 +516,7 @@ export function App({ ctx, data }) {
onColumnMoved={hasRelocate ? onColumnMoved : undefined}
/>
)}
{menu &&
{showMenu &&
renderLayer(
<HeaderMenu
layerProps={layerProps}
Expand Down
50 changes: 25 additions & 25 deletions lib/assets/data_table/build/main.js

Large diffs are not rendered by default.

0 comments on commit 6d2a3ab

Please sign in to comment.