Skip to content
New issue

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

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

Already on GitHub? # to your account

Dialog: Show Tooltip on "close" button #5436

Merged
merged 8 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/chilled-walls-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Show `Tooltip` on close button in `Dialog`
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/react/.storybook/storybook.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
border: var(--borderWidth-thin) solid var(--borderColor-sponsors-emphasis) !important;
}

.testCustomAnimation {
animation: none !important;
}

.testCustomClassnameMono {
font-family: var(--fontStack-monospace) !important;
}
6 changes: 3 additions & 3 deletions packages/react/src/Dialog/Dialog.dev.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const WithCss = ({width, height, subtitle}: DialogStoryProps) => {
{buttonType: 'danger', content: 'Delete the universe', onClick: onDialogClose},
{buttonType: 'primary', content: 'Proceed'},
]}
className="testCustomClassnameBorder"
className="testCustomClassnameBorder testCustomAnimation"
>
{lipsum}
</Dialog>
Expand Down Expand Up @@ -137,7 +137,7 @@ export const WithSx = ({width, height, subtitle}: DialogStoryProps) => {
{buttonType: 'danger', content: 'Delete the universe', onClick: onDialogClose},
{buttonType: 'primary', content: 'Proceed'},
]}
sx={{borderColor: 'accent.emphasis', borderWidth: '1px', borderStyle: 'solid'}}
sx={{borderColor: 'accent.emphasis', borderWidth: '1px', borderStyle: 'solid', animation: 'none !important'}}
Copy link
Member Author

Choose a reason for hiding this comment

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

There was a very small difference between the dev component snapshots (0.02 pixel difference). It seems like this was caused by the animation, but only affected the colorblind theme.

It would sometimes pass/fail, so I marked it off as being flaky via the custom CSS. It never affected the non-dev stories.

>
{lipsum}
</Dialog>
Expand Down Expand Up @@ -199,7 +199,7 @@ export const WithSxAndCss = ({width, height, subtitle}: DialogStoryProps) => {
{buttonType: 'danger', content: 'Delete the universe', onClick: onDialogClose},
{buttonType: 'primary', content: 'Proceed'},
]}
sx={{borderColor: 'border.accent', borderWidth: '1px', borderStyle: 'solid'}}
sx={{borderColor: 'border.accent', borderWidth: '1px', borderStyle: 'solid', animation: 'none !important'}}
className="testCustomClassnameBorder"
>
{lipsum}
Expand Down
10 changes: 5 additions & 5 deletions packages/react/src/Dialog/Dialog.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@
}

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;
}

&[data-position-regular='center'] {
border-radius: var(--borderRadius-large, var(--borderRadius-large));

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;
}
}

Expand All @@ -138,7 +138,7 @@
border-bottom-left-radius: 0;

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-slideInRight 0.25s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-slideInRight 0.25s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;
}
}

Expand Down Expand Up @@ -193,7 +193,7 @@
border-bottom-left-radius: 0;

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-slideUp 0.25s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-slideUp 0.25s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;
}
}

Expand All @@ -206,7 +206,7 @@
flex-grow: 1;

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;
}
}
}
Expand Down
15 changes: 6 additions & 9 deletions packages/react/src/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,14 @@ const StyledDialog = toggleStyledComponent(
opacity: 1;

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;
}

&[data-position-regular='center'] {
border-radius: var(--borderRadius-large, 0.75rem);

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;
}
}

Expand All @@ -290,7 +290,7 @@ const StyledDialog = toggleStyledComponent(
border-bottom-left-radius: 0;

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-slideInRight 0.25s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-slideInRight 0.25s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;
}
}

Expand Down Expand Up @@ -323,7 +323,7 @@ const StyledDialog = toggleStyledComponent(
border-bottom-left-radius: 0;

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-slideUp 0.25s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-slideUp 0.25s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;
}
}

Expand All @@ -336,7 +336,7 @@ const StyledDialog = toggleStyledComponent(
flex-grow: 1;

@media screen and (prefers-reduced-motion: no-preference) {
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;
animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;
}
}
}
Expand Down Expand Up @@ -677,10 +677,7 @@ const Buttons: React.FC<React.PropsWithChildren<{buttons: DialogButtonProps[]}>>
}

const CloseButton: React.FC<React.PropsWithChildren<{onClose: () => void}>> = ({onClose}) => {
return (
// eslint-disable-next-line primer-react/a11y-remove-disable-tooltip
<IconButton unsafeDisableTooltip={true} icon={XIcon} aria-label="Close" onClick={onClose} variant="invisible" />
)
return <IconButton icon={XIcon} aria-label="Close" onClick={onClose} variant="invisible" />
}

/**
Expand Down
Loading