Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LG-4121: popover refactor #2520

Merged
merged 19 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5522136
LG-4444: OverlayContext and useOverlay (#2454)
stephl3 Aug 13, 2024
2035613
LG-4446: refactor PopoverContext and replace PortalContext (#2456)
stephl3 Aug 16, 2024
24973e6
LG-4447: refactor Popover positioning logic and remove unused content…
stephl3 Sep 3, 2024
acfe4ca
LG-4515: replace position utils with @floating-ui/react (#2473)
stephl3 Sep 16, 2024
f367562
Update default value of Popover spacing prop from 10px to 4px (#2479)
stephl3 Sep 16, 2024
82c9341
LG-4516: deprecate justify="fit" from popover and related components …
stephl3 Sep 16, 2024
6794c10
LG-4445: add renderMode and top layer (#2482)
stephl3 Oct 4, 2024
6b07b6d
Revert LG-4444: OverlayContext and useOverlay (#2503)
stephl3 Oct 15, 2024
c695571
LG-4526: refactor popover-consuming components (#2501)
stephl3 Oct 18, 2024
21c4080
LG-4525: popover-v12 code mod (#2484)
stephl3 Oct 25, 2024
f96bde5
Fix escape key close in `Modal` (#2513)
stephl3 Oct 25, 2024
cd7d68d
Fix Copyable tooltip spec (#2519)
stephl3 Oct 25, 2024
4d645a2
Make @leafygreen-ui/leafygreen-provider changes minor (#2528)
stephl3 Nov 4, 2024
9188b61
LG-4525: Support filtering by package name in popover-v12 codemod and…
stephl3 Nov 15, 2024
b57c720
LG-4121: consolidate changesets for popover refactor (#2517)
stephl3 Nov 15, 2024
18de486
PopoverPropsProvider docs
stephl3 Nov 16, 2024
732fae5
Update Popover example to use refEl
stephl3 Nov 26, 2024
24578ce
LG-4121: Fix Safari regressions and refactor Popover (#2549)
stephl3 Nov 26, 2024
82b7417
Split up generated menu stories
stephl3 Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/chat-input-bar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@lg-chat/input-bar': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): `InputBar` renders results menu in top layer using popover API. As a result, the following props are deprecated and removed:
Comment on lines +2 to +5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is codemod-able, right? Maybe we should mention the codemod in the changeset?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's excluded from the codemod because users haven't used the props in the wild

- `portalClassName`
- `portalContainer`
- `portalRef`
- `scrollContainer`
- `usePortal`
17 changes: 17 additions & 0 deletions .changeset/chip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@leafygreen-ui/chip': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): Removes `popoverZIndex` prop because the `InlineDefinition` component instance will now render in the top layer
Comment on lines +2 to +5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could avoid a major change by just deprecating the prop, and having it not do anything. Not a huge deal though since we have so many other major changes


#### Migration guide

##### Old
```js
<Chip popoverZIndex={9999} />
```

##### New
```js
<Chip />
```
5 changes: 5 additions & 0 deletions .changeset/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-tools/cli': minor
---

Adds `--packages` flag to `lg codemod` command. Passing in this flag will specify which package names should be filtered for in a given codemod.
26 changes: 26 additions & 0 deletions .changeset/code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@leafygreen-ui/code': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): `Code` renders the copy button tooltip and language selector in the top layer using popover API. As a result, the following props are removed:
- `popoverZIndex`
- `portalClassName`
- `portalContainer`
- `scrollContainer`
- `usePortal`

#### Migration guide

Use [popover-v12 codemod](https://github.com/mongodb/leafygreen-ui/tree/main/tools/codemods#popover-v12) for migration assistance.

##### Old
```js
<Code popoverZIndex={9999} usePortal={false} />
<Code portalClassName="portal-class" usePortal />
```

##### New
```js
<Code />
<Code />
```
42 changes: 42 additions & 0 deletions .changeset/codemods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
'@lg-tools/codemods': minor
---

[LG-4525](https://jira.mongodb.org/browse/LG-4525) Adds `popover-v12` codemod which can be used to refactor popover component instances. Users can filter for specific packages using the `--packages` flag.

This codemod does the following:

1. Adds an explicit `usePortal={true}` declaration if left undefined and consolidates the `usePortal` and `renderMode` props into a single `renderMode` prop for components in the following packages:

- `@leafygreen-ui/combobox`
- `@leafygreen-ui/menu`
- `@leafygreen-ui/popover`
- `@leafygreen-ui/select`
- `@leafygreen-ui/split-button`
- `@leafygreen-ui/tooltip`

2. Removes `popoverZIndex`, `portalClassName`, `portalContainer`, `portalRef`, `scrollContainer`, and `usePortal` props from the following components:

- `@leafygreen-ui/info-sprinkle`
- `@leafygreen-ui/inline-definition`
- `@leafygreen-ui/number-input`

3. Removes `popoverZIndex`, `portalClassName`, `portalContainer`, `portalRef`, and `scrollContainer` props from the following components:

- `@leafygreen-ui/date-picker`
- `@leafygreen-ui/guide-cue`

4. Removes `popoverZIndex`, `portalClassName`, `portalContainer`, `scrollContainer`, and `usePortal` props from `Code` component in the `@leafygreen-ui/code` package

5. Removes `portalClassName`, `portalContainer`, `portalRef`, `scrollContainer`, and `usePortal` props from `SearchInput` component in the `@leafygreen-ui/search-input` package

6. Removes `shouldTooltipUsePortal` prop from `Copyable` component in the `@leafygreen-ui/copyable` package

7. Replaces `justify="fit"` prop value with `justify="middle"` for components in the following packages:

- `@leafygreen-ui/date-picker`
- `@leafygreen-ui/info-sprinkle`
- `@leafygreen-ui/inline-definition`
- `@leafygreen-ui/menu`
- `@leafygreen-ui/popover`
- `@leafygreen-ui/tooltip`
23 changes: 23 additions & 0 deletions .changeset/combobox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@leafygreen-ui/combobox': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): Replaces `usePortal` prop with `renderMode` prop. `renderMode="inline"` and `renderMode="portal"` are deprecated, and all popover elements should migrate to using the top layer. The old default was `usePortal=true`, and the new default is `renderMode="top-layer"`.

See [@leafygreen-ui/popover package 12.0.0 changelog](https://github.com/mongodb/leafygreen-ui/blob/main/packages/popover/CHANGELOG.md#1200) for more info.

#### Migration guide

Use [popover-v12 codemod](https://github.com/mongodb/leafygreen-ui/tree/main/tools/codemods#popover-v12) for migration assistance.

##### Old
```js
<Combobox popoverZIndex={9999} usePortal={false} />
<Combobox portalClassName="portal-class" usePortal />
```

##### New
```js
<Combobox popoverZIndex={9999} renderMode="inline" />
<Combobox portalClassName="portal-class" renderMode="portal" />
```
21 changes: 21 additions & 0 deletions .changeset/copyable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@leafygreen-ui/copyable': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): `Copyable` renders tooltip in the top layer using popover API. As a result, the `shouldTooltipUsePortal` prop is removed

#### Migration guide

Use [popover-v12 codemod](https://github.com/mongodb/leafygreen-ui/tree/main/tools/codemods#popover-v12) for migration assistance.

##### Old
```js
<Copyable shouldTooltipUsePortal={false} />
<Copyable shouldTooltipUsePortal />
```

##### New
```js
<Copyable />
<Copyable />
```
30 changes: 30 additions & 0 deletions .changeset/date-picker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
'@leafygreen-ui/date-picker': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): `DatePicker` renders menu, month selector, and year selector in top layer using popover API. As a result, the following props are deprecated and removed:
- `popoverZIndex`
- `portalClassName`
- `portalContainer`
- `portalRef`
- `scrollContainer`

Additional changes include:
- Deprecates and removes `justify="fit"`. Instead, use `justify="middle"`
- Removes unused `contentClassName` prop

#### Migration guide

Use [popover-v12 codemod](https://github.com/mongodb/leafygreen-ui/tree/main/tools/codemods#popover-v12) for migration assistance.

##### Old
```js
<DatePicker portalContainer={containerRef} scrollContainer={containerRef} />
<DatePicker portalClassName="portal-class" />
```

##### New
```js
<DatePicker />
<DatePicker />
```
26 changes: 26 additions & 0 deletions .changeset/guide-cue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@leafygreen-ui/guide-cue': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): `GuideCue` renders beacon and tooltip using popover API. As a result, the following props are removed:
- `popoverZIndex`
- `portalClassName`
- `portalContainer`
- `portalRef`
- `scrollContainer`

#### Migration guide

Use [popover-v12 codemod](https://github.com/mongodb/leafygreen-ui/tree/main/tools/codemods#popover-v12) for migration assistance.

##### Old
```js
<GuideCue popoverZIndex={9999} />
<GuideCue portalContainer={containerRef} scrollContainer={containerRef} />
```

##### New
```js
<GuideCue />
<GuideCue />
```
5 changes: 5 additions & 0 deletions .changeset/hooks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/hooks': minor
---

Add `useMergeRefs` hook for merging array of refs into a single memoized callback ref or `null`
31 changes: 31 additions & 0 deletions .changeset/info-sprinkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
'@leafygreen-ui/info-sprinkle': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): `InfoSprinkle` renders tooltip in the top layer using popover API. As a result, the following props are removed:
- `popoverZIndex`
- `portalClassName`
- `portalContainer`
- `portalRef`
- `scrollContainer`
- `usePortal`

Additional changes include:
- Deprecates and removes `justify="fit"`. Instead, use `justify="middle"`
- Opens tooltip immediately on hover instead of default 500ms delay

#### Migration guide

Use [popover-v12 codemod](https://github.com/mongodb/leafygreen-ui/tree/main/tools/codemods#popover-v12) for migration assistance.

##### Old
```js
<InfoSprinkle popoverZIndex={9999} usePortal={false} />
<InfoSprinkle portalClassName="portal-class" usePortal />
```

##### New
```js
<InfoSprinkle />
<InfoSprinkle />
```
32 changes: 32 additions & 0 deletions .changeset/inline-definition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
'@leafygreen-ui/inline-definition': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): `InlineDefinition` renders tooltip in the top layer using popover API. As a result, the following props are removed:
- `popoverZIndex`
- `portalClassName`
- `portalContainer`
- `portalRef`
- `scrollContainer`
- `usePortal`

Additional changes include:
- Deprecates and removes `justify="fit"`. Instead, use `justify="middle"`
- Opens tooltip immediately on hover instead of default 500ms delay
- Reorganizes file structure

#### Migration guide

Use [popover-v12 codemod](https://github.com/mongodb/leafygreen-ui/tree/main/tools/codemods#popover-v12) for migration assistance.

##### Old
```js
<InlineDefinition popoverZIndex={9999} usePortal={false} />
<InlineDefinition portalClassName="portal-class" usePortal />
```

##### New
```js
<InlineDefinition />
<InlineDefinition />
```
7 changes: 7 additions & 0 deletions .changeset/lg-provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@leafygreen-ui/leafygreen-provider': minor
---

[LG-4446](https://jira.mongodb.org/browse/LG-4446): Adds `PopoverPropsContext` to pass props to a deeply nested popover element

Additionally exposes a `forceUseTopLayer` prop in the `LeafyGreenProvider` which can be used to test interactions with all LG popover elements forcibly set to `renderMode="top-layer"`. This can help pressure test for any regressions to more confidently and safely migrate. However, this should only be used when all LG dependencies are relying on v12+ of `@leafygreen-ui/popover`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do if someone has old popover dependencies?
Should we name this prop something ugly like _internal_forcePopoverTopLayer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't do anything in those cases, but its purpose is nullified in that case since it's intended to test if using all top layer popovers is viable

@TheSonOfThomp I think the current naming is fine with me, but do you feel strongly about renaming to include that prefix pattern?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah don't feel too strongly on that, just wanted to check

26 changes: 26 additions & 0 deletions .changeset/menu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@leafygreen-ui/menu': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): Replaces `usePortal` prop with `renderMode` prop. `renderMode="inline"` and `renderMode="portal"` are deprecated, and all popover elements should migrate to using the top layer. The old default was `usePortal=true`, and the new default is `renderMode="top-layer"`.

See [@leafygreen-ui/popover package 12.0.0 changelog](https://github.com/mongodb/leafygreen-ui/blob/main/packages/popover/CHANGELOG.md#1200) for more info.

Additional changes include:
- Deprecates and removes `justify="fit"`. Instead, use `justify="middle"`

#### Migration guide

Use [popover-v12 codemod](https://github.com/mongodb/leafygreen-ui/tree/main/tools/codemods#popover-v12) for migration assistance.

##### Old
```js
<Menu popoverZIndex={9999} usePortal={false} />
<Menu portalClassName="portal-class" usePortal />
```

##### New
```js
<Menu popoverZIndex={9999} renderMode="inline" />
<Menu portalClassName="portal-class" renderMode="portal" />
```
30 changes: 30 additions & 0 deletions .changeset/number-input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
'@leafygreen-ui/number-input': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): `NumberInput` renders unit selector and tooltip in the top layer using popover API. As a result, the following props are removed:
- `popoverZIndex`
- `portalClassName`
- `portalContainer`
- `portalRef`
- `scrollContainer`
- `usePortal`

Additional changes include:
- Opens tooltip immediately on hover instead of default 500ms delay

#### Migration guide

Use [popover-v12 codemod](https://github.com/mongodb/leafygreen-ui/tree/main/tools/codemods#popover-v12) for migration assistance.

##### Old
```js
<NumberInput popoverZIndex={9999} usePortal={false} />
<NumberInput portalClassName="portal-class" usePortal />
```

##### New
```js
<NumberInput />
<NumberInput />
```
5 changes: 5 additions & 0 deletions .changeset/odd-llamas-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-tools/validate': minor
---

Updates `ignoreFilePatterns` and `depcheckOptions.ignorePatterns` to exclude validating dependencies in `*.input.*` and `*.output.*` files in `tools/codemods` directory
5 changes: 5 additions & 0 deletions .changeset/pagination.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/pagination': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): `Pagination` renders page selectors in the top layer using popover API
7 changes: 7 additions & 0 deletions .changeset/pipeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@leafygreen-ui/pipeline': major
---

[LG-4121](https://jira.mongodb.org/browse/LG-4121): `Pipeline` renders tooltip in the top layer using popover API

Additionally, the tooltip opens immediately on hover instead of default 500ms delay
Loading