-
Notifications
You must be signed in to change notification settings - Fork 70
[LG-5523] feat(drawer): add ref and tooltipEnabled props to DrawerLayout toolbarData for ToolbarIconButton integration #3142
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4721ddb
feat(toolbar): add tooltipEnabled prop to ToolbarIconButton for custo…
stephl3 4cf1b82
chore(toolbar): changeset
stephl3 0e80f09
chore(drawer): add @leafygreen-ui/guide-cue as dev dep
stephl3 d0e8648
feat(drawer): enhance DrawerToolbarLayout with ref and tooltipEnabled…
stephl3 f0a432c
chore(drawer): changeset
stephl3 4525dc2
refactor: rename tooltipEnabled prop to isTooltipEnabled
stephl3 d2a2a94
refactor(drawer): move WithGuideCue story with play test
stephl3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@leafygreen-ui/toolbar': minor | ||
--- | ||
|
||
Add `isTooltipEnabled` prop to `ToolbarIconButton` component for customizable tooltip behavior |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@leafygreen-ui/drawer': minor | ||
--- | ||
|
||
Enhance `DrawerLayout` component's `toolbarData` prop with `ref` and `isTooltipEnabled` props for `ToolbarIconButton` integration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,9 @@ | |
{ | ||
"path": "../emotion" | ||
}, | ||
{ | ||
"path": "../guide-cue" | ||
}, | ||
{ | ||
"path": "../hooks" | ||
}, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import React, { createRef } from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { axe } from 'jest-axe'; | ||
|
||
import { Toolbar } from '../Toolbar'; | ||
|
@@ -35,6 +36,48 @@ describe('packages/toolbar-icon-button', () => { | |
expect(ref.current).toBeDefined(); | ||
expect(ref.current).toBeInstanceOf(HTMLButtonElement); | ||
}); | ||
|
||
test('shows tooltip on hover when isTooltipEnabled is true', async () => { | ||
const { getByRole, findByRole } = render( | ||
<Toolbar> | ||
<ToolbarIconButton | ||
glyph="Code" | ||
label="Code Tooltip" | ||
isTooltipEnabled={true} | ||
/> | ||
</Toolbar>, | ||
); | ||
|
||
const button = getByRole('button'); | ||
userEvent.hover(button); | ||
|
||
// Tooltip should appear | ||
const tooltip = await findByRole('tooltip'); | ||
expect(tooltip).toBeInTheDocument(); | ||
expect(tooltip).toHaveTextContent('Code Tooltip'); | ||
}); | ||
|
||
test('does not show tooltip on hover when isTooltipEnabled is false', async () => { | ||
const { getByRole, queryByRole } = render( | ||
<Toolbar> | ||
<ToolbarIconButton | ||
glyph="Code" | ||
label="Code Tooltip" | ||
isTooltipEnabled={false} | ||
/> | ||
</Toolbar>, | ||
); | ||
|
||
const button = getByRole('button'); | ||
userEvent.hover(button); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
|
||
// Wait a bit to ensure tooltip would have appeared if enabled | ||
await new Promise(resolve => setTimeout(resolve, 100)); | ||
|
||
// Tooltip should not appear | ||
const tooltip = queryByRole('tooltip'); | ||
expect(tooltip).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
/* eslint-disable jest/no-disabled-tests */ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
userEvent.hover
call should be awaited since it returns a Promise in modern versions of @testing-library/user-event.Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only in RTL 14