Skip to content

Commit 3d64531

Browse files
TheSonOfThompCopilotstephl3
authored
[LG-5342] Menu height update (#3237)
* Updates Popover RefEl calculation hook * adds documentation to useObjectDependency * Adds maxHeight/maxWidth props to popover * install faker * Update Popover.types.ts * Create popover-max-height.md * Update Popover.styles.ts * adds moving Popover story * Update Popover.tsx * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * menu dev deps * removes redundant useMemo from useMenuHeight * Update Menu.tsx * Refactors menu to use Popover max height * fix css * Squashed commit of the following: commit ef96910 Author: Adam Thompson <[email protected]> Date: Thu Oct 16 18:48:12 2025 -0400 adds moving Popover story commit 17c0f61 Author: Adam Thompson <[email protected]> Date: Thu Oct 16 16:34:07 2025 -0400 Update Popover.styles.ts commit 71837b0 Author: Adam Thompson <[email protected]> Date: Thu Oct 16 16:02:02 2025 -0400 Create popover-max-height.md commit 764d15c Author: Adam Thompson <[email protected]> Date: Thu Oct 16 15:56:12 2025 -0400 Update Popover.types.ts commit 6414ff2 Author: Adam Thompson <[email protected]> Date: Thu Oct 16 15:56:06 2025 -0400 install faker commit 9419b41 Author: Adam Thompson <[email protected]> Date: Thu Oct 16 15:12:35 2025 -0400 Adds maxHeight/maxWidth props to popover commit 175de17 Author: Adam Thompson <[email protected]> Date: Wed Oct 15 16:37:22 2025 -0400 adds documentation to useObjectDependency * Update Popover.tsx * add MovingMenuTrigger story * changesets * Update .changeset/popover-max-height.md Co-authored-by: Stephen Lee <[email protected]> * Update packages/popover/src/Popover/Popover.types.ts Co-authored-by: Stephen Lee <[email protected]> * Update Popover.stories.tsx * Squashed commit of the following: commit 4ac4fd2 Author: Adam Thompson <[email protected]> Date: Wed Oct 22 11:11:00 2025 -0400 Update Popover.stories.tsx commit c312739 Merge: 6a573d6 392b350 Author: Adam Thompson <[email protected]> Date: Tue Oct 21 17:26:37 2025 -0400 Merge branch 'main' into LG-5627-popover-height commit 392b350 Author: Adam Rasheed <[email protected]> Date: Tue Oct 21 12:36:10 2025 -0700 [LG-2187] feat: Menu Prop Updates (#3240) * [LG-2187] feat: Menu Prop Updates * fixed contextMenu * cleanup * updated changeset * rm old changeset * updated ContextMenu implementation commit c6b4d3f Author: Adam Thompson <[email protected]> Date: Tue Oct 21 12:15:31 2025 -0400 [LG-5635] chore: Fixes flaky icon builds (#3244) * create new node externals instance * rm debug script * add postbuild * Delete tsconfig.json * rm extra console.logs * Update index.ts * Create icon-build-process.md * Update index.ts commit 2d50b59 Author: Terrence Keane <[email protected]> Date: Tue Oct 21 10:50:24 2025 -0400 [LG-5098] feat(CodeEditor): adds custom search panel (#3186) * feat(SearchForm): add SearchForm component * feat(SearchForm): implement SearchForm component with toggle functionality and styling - Added the SearchForm component to the CodeEditor, featuring a toggle button for expanding and collapsing the search input. - Integrated LeafyGreen UI components for consistent styling and functionality. - Created a new story for SearchForm in Storybook to demonstrate its usage and appearance. - Updated CodeEditor to include the SearchForm, enhancing user interaction capabilities. * refactor(CodeEditor): add back in panel import * refactor(SearchForm): further correct styling * WIP * refactor(SearchForm): Further correct styling * make top row height more dynamic * fix top section height * WIP * Fix width styling * Fix box shadow * Add find functionality * Remove unnecessary space * Add find selected index rendering * Add replace functionality * Fix keyboard shortcuts * rename SearchForm to SearchPanel * fix top padding * Allow search panel to be disabled * fix dep array * only load search module when needed * fix darkmode and font size * fix deps * Fix focus and imports * prevent panel from overflowing editor * add filter menu * pull out all handler * add search panel tests * fix tests * changeset * remove unused styles * update changeset * ignore react client TS issue * add non-panel style * fix dep arr * Fix react 17 bug * Copilot feedback * Missed copilot feedback * CR first pass * Update search match background to match Code highlight * Fix R17 import * Revert "Update search match background to match Code highlight" This reverts commit 6bf2b88. * Fix darkmode implementation * Fix search panel sizing * Extract search logic into hook * Remove unused variables * Reapply "Update search match background to match Code highlight" This reverts commit ec510e5. * Possible color pallette for find * Remove 'all' option * Fix build? * Add require v import comment * Fix hook logic * refactor(SearchPanel): update selected index handling to use searchQuery parameter for improved accuracy * fix(SearchPanel): remove TypeScript error suppression for ref prop in TextInput component * fix(SearchPanel): adjust positioning and add right border to enhance layout commit 090b547 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue Oct 21 09:39:53 2025 -0400 Version Packages (#3231) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> commit 1d67179 Author: Nima Taheri <[email protected]> Date: Mon Oct 20 14:21:03 2025 -0700 LG-5588 Add Bar series for charts (#3206) * feat: add Bar series * refactor: change makeLineData to makeSeriesData * docs: rename Basic to Line, then add a Bar to charts-core storybook * feat: add changeset commit 71ff953 Author: Stephen Lee <[email protected]> Date: Mon Oct 20 13:45:30 2025 -0700 fix(input-bar): change shouldRenderGradient default to false (#3194) (#3243) * fix(input-bar): reverse default of shouldRenderGradient prop * chore(input-bar): changeset * refactor(input-bar): remove log for shouldRenderGradient prop to avoid major change * [LG-5600] feat(input-bar): add onClickStop prop and update button disabled logic (#3195) * feat(input-bar): add onClickStop prop and fix disabled state * docs(input-bar): README * refactor(input-bar): reorg buttons and rename prop commit 7fc3077 Author: Adam Rasheed <[email protected]> Date: Mon Oct 20 13:23:40 2025 -0700 [LG-2163] chore: Select component removed readOnly prop (#3241) commit 82c0efe Author: Adam Thompson <[email protected]> Date: Mon Oct 20 14:20:20 2025 -0400 chore: mv build command to package json (#3242) * mv build command to package json * Update package.json commit 95a6cd3 Author: Adam Thompson <[email protected]> Date: Mon Oct 20 12:30:13 2025 -0400 Update release.yml (#3239) commit 1a9926f Author: Stephen Lee <[email protected]> Date: Mon Oct 20 09:24:27 2025 -0700 [LG-5579] feat(feature-walls): migrate package from private to public scope (#3229) * chore(feature-walls): move from @lg-private to @leafygreen-ui scope * docs: add feature-walls to root readme * docs(vertical-stepper): consistent docs * refactor(feature-walls): remove react-transition-group dep in favor of css transition * chore(feature-walls): changeset * fix(feature-walls): Accordion tests * fix(feature-walls): copilot feedback, cleanup, use only CSS for ExpandableGrid * fix(feature-walls): types * test(feature-walls): generated stories use LG provider * fix(feature-walls): dark mode propagation commit 7f7c385 Author: Terrence Keane <[email protected]> Date: Fri Oct 17 16:31:56 2025 -0400 fix(skeleton-loader): enhance accessibility for TableSkeleton component (#3233) * Add VisuallyHidden "Loading" text to table headers without column labels to improve screen reader support. * Update tests to verify accessibility compliance and ensure no violations are present. * Include '@leafygreen-ui/a11y' as a dependency in the skeleton-loader package. commit 51c453b Author: Terrence Keane <[email protected]> Date: Fri Oct 17 14:11:56 2025 -0400 [LG-3993] fix(Select): VO properly announces value and label (#3218) * Correctly read label and value when label included * Add comment * changeset * Enhance `Select` component accessibility by adding `aria-current` attribute for screen readers and ensuring proper announcement of `aria-label` with selected values. * Refactor `aria-label` attributes in DatePickerMonth and DatePickerYear components for improved accessibility and consistency. * Remove aria-current logic from Select component * Remove aria-current attribute assertions from Select component tests --------- Co-authored-by: Adam Thompson <[email protected]> commit bd83675 Author: Stephen Lee <[email protected]> Date: Fri Oct 17 10:12:27 2025 -0700 feat(chat): style improvements (#3238) * fix(drawer): overflow shadow only renders when scrollable is true (#3210) * fix(drawer): overflow shadow only renders when scrollable is true * chore(drawer): changeset * fix(input-bar): center align disclaimer text (#3211) * fix(input-bar): center align disclaimer * chore(input-bar): changeset * feat(chat): update layout to use flexible height containers (#3212) * fix(leafygreen-chat-provider): set height to 100% * chore(leafygreen-chat-provider): changeset * feat(message-feed): remove fixed default height for MessageFeed component * chore(message-feed): changeset * fix(fixed-chat-window): add explicit height and fix stories * chore(fixed-chat-window): changeset * chore(chat-window): install @storybook/test and @leafygreen-ui/drawer dev deps * test(chat-window): add InDrawerLayout story and update baseMessages * feat(chat-window): add hidden spacer to fix vertical message flow and remove redundant container element * chore: changesets * fix(chat): stories commit f3a8bdc Author: Adam Thompson <[email protected]> Date: Fri Oct 17 12:52:36 2025 -0400 LG-5609 Emotion version script (#3221) * postversion * Create emotion-version.md * Revert "postversion" This reverts commit 12f41d0. * build pre version in ci * Update emotion-version.md commit 6a573d6 Merge: 29c2c23 b2d6795 Author: Adam Thompson <[email protected]> Date: Fri Oct 17 12:51:34 2025 -0400 Merge branch 'main' into LG-5627-popover-height commit 29c2c23 Author: Adam Thompson <[email protected]> Date: Fri Oct 17 12:50:31 2025 -0400 Update packages/popover/src/Popover/Popover.types.ts Co-authored-by: Stephen Lee <[email protected]> commit 1ec9bf8 Author: Adam Thompson <[email protected]> Date: Fri Oct 17 12:50:11 2025 -0400 Update .changeset/popover-max-height.md Co-authored-by: Stephen Lee <[email protected]> commit b2d6795 Author: Adam Thompson <[email protected]> Date: Fri Oct 17 10:28:35 2025 -0400 [LG-4735] Spinner codemod (#3228) * Creates loading spinner * creates story * lgids and test utils * Update README.md * deprecate Spinner from loading-indicator * changesets * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * mv story * update animation timing * replace loading spinner * adds test harnesses * fix test references * adds named exports * changeset * Update loading-spinner.md * update rotation speed * Update README.md * Updates sizing to match Figma * fixes * Update loading-spinner.md * adds codemod * update description comment * Update loading-spinner.md * lint * fixes xl tests * adds tree shake tests * Update tools/codemods/src/codemods/loading-spinner-v5/transform.ts Co-authored-by: Copilot <[email protected]> * Update tools/codemods/README.md Co-authored-by: Copilot <[email protected]> * fix treeshake test --------- Co-authored-by: Copilot <[email protected]> commit 2e06c1d Author: Stephen Lee <[email protected]> Date: Fri Oct 17 07:24:42 2025 -0700 fix(date-picker): flaky spec (#3235) * add inline definition snapshot delay * Update packages/menu/src/Menu.stories.tsx Co-authored-by: Copilot <[email protected]> * lint fix --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Stephen Lee <[email protected]>
1 parent 83b0b92 commit 3d64531

File tree

11 files changed

+123
-46
lines changed

11 files changed

+123
-46
lines changed

.changeset/menu-height-popover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@leafygreen-ui/menu': minor
3+
---
4+
5+
Updates Popover dependency. Menu height calculation is now handled by the Popover package.

.changeset/popover-max-height.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ If the provided value is _greater than_ the available space above/below (for hei
99
the size will be restricted to the available space (i.e. the popover will not overflow the viewport).
1010

1111
Note: Any `max-height` or `max-width` value applied with additional CSS will take precedence, and will override the "available space" calculation
12+
13+
Exports `popoverCSSProperties` constant for use in components that extend popover

packages/hooks/src/useAvailableSpace/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import useViewportSize from '../useViewportSize';
44
* Returns the maximum space available above or below the source trigger
55
* @param triggerRef The `ref` object attached to the source trigger
66
* @param margin The space around the trigger
7+
*
8+
* Note: You may not need this hook.
9+
* Popovers now adjust their size automatically based on the available space using Floating UI
10+
* @see packages/popover/src/Popover/Popover.tsx
711
*/
812
const useAvailableSpace = (
913
triggerRef?: React.RefObject<HTMLElement>,

packages/menu/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"devDependencies": {
3535
"@leafygreen-ui/button": "workspace:^",
3636
"@leafygreen-ui/text-input": "workspace:^",
37-
"@lg-tools/build": "workspace:^"
37+
"@lg-tools/build": "workspace:^",
38+
"@storybook/test": "8.6.14"
3839
},
3940
"peerDependencies": {
4041
"@leafygreen-ui/leafygreen-provider": ">=3.2.0"

packages/menu/src/Menu.stories.tsx

Lines changed: 92 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/* eslint-disable react-hooks/rules-of-hooks */
22

3-
import React, { useState } from 'react';
3+
import React, { useRef, useState } from 'react';
44
import {
55
storybookArgTypes,
66
storybookExcludedControlParams,
77
type StoryMetaType,
88
} from '@lg-tools/storybook-utils';
99
import { StoryObj } from '@storybook/react';
10-
import { userEvent, within } from '@storybook/test';
10+
import { fn, userEvent, within } from '@storybook/test';
1111

1212
import Button from '@leafygreen-ui/button';
13-
import { css } from '@leafygreen-ui/emotion';
13+
import { css, cx } from '@leafygreen-ui/emotion';
1414
import Icon from '@leafygreen-ui/icon';
1515
import CaretDown from '@leafygreen-ui/icon/dist/CaretDown';
1616
import CloudIcon from '@leafygreen-ui/icon/dist/Cloud';
@@ -20,6 +20,8 @@ import { TestUtils } from '@leafygreen-ui/popover';
2020

2121
const { getAlign, getJustify } = TestUtils;
2222

23+
import { useEventListener } from '@leafygreen-ui/hooks';
24+
2325
import {
2426
Menu,
2527
MenuGroup,
@@ -100,6 +102,7 @@ const meta: StoryMetaType<typeof Menu> = {
100102
darkMode: false,
101103
renderDarkMenu: false,
102104
variant: MenuVariant.Default,
105+
onOpen: fn(),
103106
},
104107
argTypes: {
105108
open: {
@@ -476,3 +479,89 @@ export const InitialLongMenuOpen: InitialLongMenuOpenStory = {
476479
),
477480
],
478481
};
482+
483+
export const MovingMenuTrigger = () => {
484+
const markerStyles = css`
485+
position: absolute;
486+
color: black;
487+
text-align: center;
488+
outline: 1px solid black;
489+
cursor: default;
490+
`;
491+
492+
const [open, setOpen] = useState(false);
493+
const [position, setPosition] = useState({ top: 0, left: 0 });
494+
const anchorRef = useRef<HTMLDivElement>(null);
495+
useEventListener(
496+
'contextmenu',
497+
event => {
498+
event.preventDefault();
499+
const { clientX, clientY } = event;
500+
setOpen(true);
501+
setPosition({ top: clientY, left: clientX });
502+
},
503+
{ dependencies: [setPosition, setOpen] },
504+
);
505+
useEventListener(
506+
'click',
507+
event => {
508+
event.preventDefault();
509+
if (event.buttons === 2) return;
510+
setOpen(false);
511+
},
512+
{ dependencies: [setOpen] },
513+
);
514+
515+
return (
516+
<div className="App">
517+
<div
518+
ref={anchorRef}
519+
style={{ position: 'absolute', width: 1, height: 1, ...position }}
520+
/>
521+
<div
522+
className={cx(
523+
markerStyles,
524+
css`
525+
top: 40vh;
526+
left: 50vw;
527+
`,
528+
)}
529+
>
530+
Click here for a shorter menu
531+
</div>
532+
<div
533+
className={cx(
534+
markerStyles,
535+
css`
536+
top: 10vh;
537+
left: 50vw;
538+
`,
539+
)}
540+
>
541+
Click here for a long menu
542+
</div>
543+
<Menu refEl={anchorRef} open={open} maxHeight={Number.MAX_SAFE_INTEGER}>
544+
<MenuItem>Item #1</MenuItem>
545+
<MenuItem>Item #2</MenuItem>
546+
<MenuItem>Item #3</MenuItem>
547+
<MenuItem>Item #4</MenuItem>
548+
<MenuItem>Item #5</MenuItem>
549+
<MenuItem>Item #6</MenuItem>
550+
<MenuItem>Item #7</MenuItem>
551+
<MenuItem>Item #8</MenuItem>
552+
<MenuItem>Item #9</MenuItem>
553+
<MenuItem>Item #10</MenuItem>
554+
<MenuItem>Item #11</MenuItem>
555+
<MenuItem>Item #12</MenuItem>
556+
<MenuItem>Item #13</MenuItem>
557+
<MenuItem>Item #14</MenuItem>
558+
<MenuItem>Item #15</MenuItem>
559+
<MenuItem>Item #16</MenuItem>
560+
<MenuItem>Item #17</MenuItem>
561+
<MenuItem>Item #18</MenuItem>
562+
<MenuItem>Item #19</MenuItem>
563+
<MenuItem>Item #20</MenuItem>
564+
</Menu>
565+
</div>
566+
);
567+
};

packages/menu/src/Menu/Menu.styles.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { transparentize } from 'polished';
33
import { css } from '@leafygreen-ui/emotion';
44
import { Theme } from '@leafygreen-ui/lib';
55
import { palette } from '@leafygreen-ui/palette';
6+
import { popoverCSSProperties } from '@leafygreen-ui/popover';
67
import { color, spacing } from '@leafygreen-ui/tokens';
78

89
import { menuColor } from '../styles';
@@ -14,12 +15,15 @@ export interface MenuStyleArgs {
1415
variant: MenuVariant;
1516
}
1617

18+
export const DEFAULT_MAX_HEIGHT = 344;
19+
export const DEFAULT_WIDTH = 210;
1720
const DEFAULT_MENU_PADDING = spacing[300];
1821
const COMPACT_MENU_PADDING = spacing[150];
1922

2023
export const getMenuStyles = ({ theme, variant }: MenuStyleArgs) => {
2124
return css`
22-
width: 210px;
25+
width: ${DEFAULT_WIDTH}px;
26+
max-height: var(${popoverCSSProperties.maxHeight}, ${DEFAULT_MAX_HEIGHT});
2327
border-radius: ${spacing[300]}px;
2428
overflow: auto;
2529
padding: ${variant === MenuVariant.Default

packages/menu/src/Menu/Menu.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
getDescendantById,
55
useInitDescendants,
66
} from '@leafygreen-ui/descendants';
7-
import { css, cx } from '@leafygreen-ui/emotion';
7+
import { cx } from '@leafygreen-ui/emotion';
88
import { useBackdropClick, useEventListener } from '@leafygreen-ui/hooks';
99
import { useDarkMode } from '@leafygreen-ui/leafygreen-provider';
1010
import {
@@ -13,11 +13,12 @@ import {
1313
keyMap,
1414
Theme,
1515
} from '@leafygreen-ui/lib';
16-
import Popover, {
16+
import {
1717
Align,
1818
DismissMode,
1919
getPopoverRenderModeProps,
2020
Justify,
21+
Popover,
2122
RenderMode,
2223
} from '@leafygreen-ui/popover';
2324

@@ -28,8 +29,9 @@ import {
2829
} from '../MenuContext/MenuContext';
2930
import { getLgIds } from '../utils';
3031

31-
import { useMenuHeight } from './utils/useMenuHeight';
3232
import {
33+
DEFAULT_MAX_HEIGHT,
34+
DEFAULT_WIDTH,
3335
getDarkInLightModeMenuStyles,
3436
getMenuStyles,
3537
scrollContainerStyle,
@@ -63,7 +65,7 @@ export const Menu = React.forwardRef<HTMLDivElement, MenuProps>(function Menu(
6365
onOpen,
6466
onClose,
6567
spacing = 6,
66-
maxHeight = 344,
68+
maxHeight = DEFAULT_MAX_HEIGHT,
6769
initialOpen = false,
6870
open: controlledOpen,
6971
setOpen: controlledSetOpen,
@@ -131,12 +133,6 @@ export const Menu = React.forwardRef<HTMLDivElement, MenuProps>(function Menu(
131133
[setOpen, shouldClose, triggerRef],
132134
);
133135

134-
const maxMenuHeightValue = useMenuHeight({
135-
refEl: triggerRef,
136-
spacing,
137-
maxHeight,
138-
});
139-
140136
useBackdropClick(handleClose, [popoverRef, triggerRef], {
141137
enabled: open,
142138
allowPropagation: true,
@@ -244,16 +240,15 @@ export const Menu = React.forwardRef<HTMLDivElement, MenuProps>(function Menu(
244240
adjustOnMutation={adjustOnMutation}
245241
onEntered={handlePopoverOpen}
246242
onExited={handlePopoverClose}
243+
maxHeight={maxHeight}
244+
maxWidth={DEFAULT_WIDTH}
247245
ref={popoverRef}
248246
{...popoverProps}
249247
>
250248
<div
251249
data-theme={theme}
252250
className={cx(
253251
getMenuStyles({ theme, variant }),
254-
css`
255-
max-height: ${maxMenuHeightValue};
256-
`,
257252
{
258253
// TODO: Remove dark-in-light mode styles
259254
// after https://jira.mongodb.org/browse/LG-3974

packages/menu/src/Menu/utils/useMenuHeight.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/popover/src/Popover/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export { Popover } from './Popover';
2-
export { contentClassName } from './Popover.styles';
2+
export { contentClassName, popoverCSSProperties } from './Popover.styles';
33
export { getAlign, getJustify } from './Popover.testutils';
44
export {
55
Align,

packages/popover/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export {
1212
type ElementPosition,
1313
Justify,
1414
Popover,
15+
popoverCSSProperties,
1516
type PopoverProps,
1617
type PopoverRenderModeProps,
1718
RenderMode,

0 commit comments

Comments
 (0)