Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 677
Update the default value of unsafeDisableTooltip to false and remove redundant props and wrappers#4702
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
Uh oh!
There was an error while loading. Please reload this page.
Update the default value of unsafeDisableTooltip to false and remove redundant props and wrappers
#4702
Changes from all commits
af79a10fdb2dae71bfea391863826f6482af5ffdc451ee65fa659cc9fd6bd57File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "@primer/react": minor | ||
| --- | ||
| IconButton: Enable tooltips by default in icon buttons by updating the default value of `unsafeDisableTooltip` to `false`. | ||
| This is a behaviour change in icon buttons, please upgrade with a caution. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -11,6 +11,7 @@ import type {ComponentProps} from './utils/types' | ||
| import {useRefObjectAsForwardedRef} from './hooks/useRefObjectAsForwardedRef' | ||
| import {XIcon} from '@primer/octicons-react' | ||
| // Dialog v1 | ||
Member 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. Classic! 😅 | ||
| const noop = () => null | ||
| type StyledDialogBaseProps = { | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| import React, {useState, useRef} from 'react' | ||
| import {Dialog, Box, Text} from '..' | ||
| import {Button} from '../deprecated' | ||
| import {Dialog, Box, Text, Button} from '..' | ||
| import {render as HTMLRender, fireEvent} from '@testing-library/react' | ||
| import axe from 'axe-core' | ||
| import {behavesAsComponent, checkExports} from '../utils/testing' | ||
| @@ -71,6 +70,36 @@ const DialogWithCustomFocusRef = () => { | ||
| ) | ||
| } | ||
| const DialogWithCustomFocusRefAndReturnFocusRef = () => { | ||
| const [isOpen, setIsOpen] = useState(true) | ||
| const returnFocusRef = useRef(null) | ||
| const buttonRef = useRef(null) | ||
| return ( | ||
| <div> | ||
| <Button data-testid="trigger-button" ref={returnFocusRef} onClick={() => setIsOpen(true)}> | ||
| Show Dialog | ||
| </Button> | ||
| <Dialog | ||
| returnFocusRef={returnFocusRef} | ||
| isOpen={isOpen} | ||
| initialFocusRef={buttonRef} | ||
| onDismiss={() => setIsOpen(false)} | ||
| aria-labelledby="header" | ||
| > | ||
| <div data-testid="inner"> | ||
| <Dialog.Header id="header">Title</Dialog.Header> | ||
| <Box p={3}> | ||
| <Text fontFamily="sans-serif">Some content</Text> | ||
| <button data-testid="inner-button" ref={buttonRef}> | ||
| hi | ||
| </button> | ||
| </Box> | ||
| </div> | ||
| </Dialog> | ||
| </div> | ||
| ) | ||
| } | ||
| describe('Dialog', () => { | ||
| // because Dialog returns a React fragment the as and sx tests fail always, so they are skipped | ||
| behavesAsComponent({ | ||
| @@ -140,7 +169,9 @@ describe('Dialog', () => { | ||
| }) | ||
| it('Returns focus to returnFocusRef on escape', async () => { | ||
| const {getByTestId, queryByTestId} = HTMLRender(<Component />) | ||
MemberAuthor 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. I had an issue with this existing component. It was supposed to go back to the return ref after pressing the ESC twice (First closing the tooltip, second closing the dialog) but for some reason it didn't work, even though I waited for the previous keyboard event to be completed. This test wasn't about the tooltip itself; it is about the Dialog so I updated to use a different dialog but let me know if I am misinterpreting the issue I encountered. | ||
| const {getByTestId, queryByTestId} = HTMLRender(<DialogWithCustomFocusRefAndReturnFocusRef />) | ||
| const innerButton = getByTestId('inner-button') | ||
| expect(document.activeElement).toEqual(innerButton) | ||
| expect(getByTestId('inner')).toBeTruthy() | ||
| fireEvent.keyDown(document.body, {key: 'Escape'}) | ||
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.
👍 Good to know!