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

feat(dialog): use native HTML dialog element #2078

Open
wants to merge 51 commits into
base: staging/cubone
Choose a base branch
from

Conversation

adamjohnson
Copy link
Collaborator

@adamjohnson adamjohnson commented Dec 6, 2024

What I did

  1. This is a continuation of feat(dialog): use native HTML dialog element #1865. Opening this as a separate PR because of merge conflicts in 1865.
  2. Please review the PR body and comments thoroughly from 1865 for changes
    • Highlights:
      • Now uses the native HTML <dialog> element.
      • Added the accessible-label property
      • Improved modal styles
      • Focus trapping
      • Updated a11y docs
      • rh-surface wrapping only <dialog> element

Testing Instructions

  1. Visit the DP Demo.
  2. View the other demos:
  3. Add various elements to modal header, body, footer
  4. Test variants (variant="small" etc and position="top")
  5. Check a11y
  6. Check for appropriate spacing

Notes to Reviewers

Docs updates:

  • Some docs on the Guidelines page are incorrect as they have the modal body scrolling independently from the header and footer. This is not possible short of a variant.
  • Guidelines for the video player close button location differ from actual implementation (update image)
  • Guidelines for Overflow content differ from implementation (update text, image)
  • Border radius of dialog in images

Closes #1242 and #1238.

@adamjohnson adamjohnson added this to the 2025/Q1 — Cubone release milestone Dec 6, 2024
@adamjohnson adamjohnson self-assigned this Dec 6, 2024
Copy link

changeset-bot bot commented Dec 6, 2024

🦋 Changeset detected

Latest commit: 6745875

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@rhds/elements Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Dec 6, 2024

Deploy Preview for red-hat-design-system ready!

Name Link
🔨 Latest commit 6745875
🔍 Latest deploy log https://app.netlify.com/sites/red-hat-design-system/deploys/67816b795f3bc200083a8212
😎 Deploy Preview https://deploy-preview-2078--red-hat-design-system.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Dec 6, 2024

Size Change: +240 B (+0.12%)

Total Size: 208 kB

Filename Size Change
./elements/rh-dialog/rh-dialog.js 5.02 kB +240 B (+5.02%) 🔍
ℹ️ View Unchanged
Filename Size
./elements.js 473 B
./elements/rh-accordion/context.js 162 B
./elements/rh-accordion/rh-accordion-header.js 2.75 kB
./elements/rh-accordion/rh-accordion-panel.js 1.35 kB
./elements/rh-accordion/rh-accordion.js 3.21 kB
./elements/rh-alert/rh-alert.js 4.31 kB
./elements/rh-audio-player/rh-audio-player-about.js 1.85 kB
./elements/rh-audio-player/rh-audio-player-rate-stepper.js 1.85 kB
./elements/rh-audio-player/rh-audio-player-scrolling-text-overflow.js 1.53 kB
./elements/rh-audio-player/rh-audio-player-subscribe.js 1.43 kB
./elements/rh-audio-player/rh-audio-player.js 13.2 kB
./elements/rh-audio-player/rh-cue.js 2 kB
./elements/rh-audio-player/rh-transcript.js 2.75 kB
./elements/rh-avatar/random-pattern-controller.js 2.72 kB
./elements/rh-avatar/rh-avatar.js 2.9 kB
./elements/rh-back-to-top/rh-back-to-top.js 2.1 kB
./elements/rh-badge/rh-badge.js 1.55 kB
./elements/rh-blockquote/rh-blockquote.js 1.48 kB
./elements/rh-breadcrumb/rh-breadcrumb.js 1.5 kB
./elements/rh-button/rh-button.js 4.24 kB
./elements/rh-card/rh-card.js 3.64 kB
./elements/rh-code-block/prism.css.js 822 B
./elements/rh-code-block/prism.js 572 B
./elements/rh-code-block/rh-code-block.js 7.25 kB
./elements/rh-cta/rh-cta.js 3.98 kB
./elements/rh-dialog/yt-api.js 617 B
./elements/rh-footer/rh-footer-block.js 766 B
./elements/rh-footer/rh-footer-copyright.js 362 B
./elements/rh-footer/rh-footer-links.js 1.17 kB
./elements/rh-footer/rh-footer-social-link.js 964 B
./elements/rh-footer/rh-footer-universal.js 4.05 kB
./elements/rh-footer/rh-footer.js 5.01 kB
./elements/rh-health-index/rh-health-index.js 2.35 kB
./elements/rh-icon/rh-icon.js 2.35 kB
./elements/rh-icon/ssr.js 181 B
./elements/rh-menu/rh-menu.js 1.29 kB
./elements/rh-navigation-secondary/rh-navigation-secondary-dropdown.js 2.47 kB
./elements/rh-navigation-secondary/rh-navigation-secondary-menu-section.js 1.35 kB
./elements/rh-navigation-secondary/rh-navigation-secondary-menu.js 1.75 kB
./elements/rh-navigation-secondary/rh-navigation-secondary-overlay.js 571 B
./elements/rh-navigation-secondary/rh-navigation-secondary.js 5.31 kB
./elements/rh-navigation-secondary/test/fixtures.js 769 B
./elements/rh-pagination/rh-pagination.js 5.46 kB
./elements/rh-site-status/rh-site-status.js 2.5 kB
./elements/rh-skip-link/rh-skip-link.js 1.24 kB
./elements/rh-spinner/rh-spinner.js 1.43 kB
./elements/rh-stat/rh-stat.js 2.2 kB
./elements/rh-subnav/rh-subnav.js 2.73 kB
./elements/rh-surface/rh-surface.js 1.14 kB
./elements/rh-surface/test/elements.js 423 B
./elements/rh-switch/rh-switch.js 2.93 kB
./elements/rh-table/rh-sort-button.js 1.49 kB
./elements/rh-table/rh-table.js 3.54 kB
./elements/rh-tabs/context.js 160 B
./elements/rh-tabs/rh-tab-panel.js 1.04 kB
./elements/rh-tabs/rh-tab.js 3.02 kB
./elements/rh-tabs/rh-tabs.js 3.77 kB
./elements/rh-tag/rh-tag.js 2.84 kB
./elements/rh-tile/rh-tile-group.js 1.81 kB
./elements/rh-tile/rh-tile.js 5.15 kB
./elements/rh-timestamp/rh-timestamp.js 983 B
./elements/rh-tooltip/rh-tooltip.js 2.73 kB
./elements/rh-video-embed/rh-video-embed.js 4.64 kB
./lib/context/color/consumer.js 1.41 kB
./lib/context/color/controller.js 947 B
./lib/context/color/provider.js 2.18 kB
./lib/context/event.js 593 B
./lib/context/headings/consumer.js 722 B
./lib/context/headings/controller.js 1.12 kB
./lib/context/headings/provider.js 1.24 kB
./lib/DirController.js 565 B
./lib/elements/rh-context-demo/rh-context-demo.js 1.28 kB
./lib/elements/rh-context-picker/rh-context-picker.js 2.24 kB
./lib/environment.js 194 B
./lib/functions.js 175 B
./lib/I18nController.js 1.38 kB
./lib/ScreenSizeController.js 849 B
./lib/ssr-controller.js 251 B
./react/rh-accordion/rh-accordion-header.js 199 B
./react/rh-accordion/rh-accordion-panel.js 185 B
./react/rh-accordion/rh-accordion.js 215 B
./react/rh-alert/rh-alert.js 184 B
./react/rh-audio-player/rh-audio-player-about.js 191 B
./react/rh-audio-player/rh-audio-player-rate-stepper.js 213 B
./react/rh-audio-player/rh-audio-player-scrolling-text-overflow.js 214 B
./react/rh-audio-player/rh-audio-player-subscribe.js 196 B
./react/rh-audio-player/rh-audio-player.js 183 B
./react/rh-audio-player/rh-cue.js 195 B
./react/rh-audio-player/rh-transcript.js 207 B
./react/rh-avatar/rh-avatar.js 173 B
./react/rh-back-to-top/rh-back-to-top.js 183 B
./react/rh-badge/rh-badge.js 174 B
./react/rh-blockquote/rh-blockquote.js 179 B
./react/rh-breadcrumb/rh-breadcrumb.js 179 B
./react/rh-button/rh-button.js 174 B
./react/rh-card/rh-card.js 172 B
./react/rh-code-block/rh-code-block.js 181 B
./react/rh-cta/rh-cta.js 170 B
./react/rh-dialog/rh-dialog.js 203 B
./react/rh-footer/rh-footer-block.js 184 B
./react/rh-footer/rh-footer-copyright.js 187 B
./react/rh-footer/rh-footer-links.js 185 B
./react/rh-footer/rh-footer-social-link.js 193 B
./react/rh-footer/rh-footer-universal.js 188 B
./react/rh-footer/rh-footer.js 174 B
./react/rh-health-index/rh-health-index.js 184 B
./react/rh-icon/rh-icon.js 202 B
./react/rh-menu/rh-menu.js 173 B
./react/rh-navigation-secondary/rh-navigation-secondary-dropdown.js 217 B
./react/rh-navigation-secondary/rh-navigation-secondary-menu-section.js 205 B
./react/rh-navigation-secondary/rh-navigation-secondary-menu.js 199 B
./react/rh-navigation-secondary/rh-navigation-secondary-overlay.js 201 B
./react/rh-navigation-secondary/rh-navigation-secondary.js 213 B
./react/rh-pagination/rh-pagination.js 178 B
./react/rh-site-status/rh-site-status.js 181 B
./react/rh-skip-link/rh-skip-link.js 181 B
./react/rh-spinner/rh-spinner.js 175 B
./react/rh-stat/rh-stat.js 171 B
./react/rh-subnav/rh-subnav.js 175 B
./react/rh-surface/rh-surface.js 175 B
./react/rh-switch/rh-switch.js 185 B
./react/rh-table/rh-sort-button.js 213 B
./react/rh-table/rh-table.js 174 B
./react/rh-tabs/rh-tab-panel.js 181 B
./react/rh-tabs/rh-tab.js 187 B
./react/rh-tabs/rh-tabs.js 174 B
./react/rh-tag/rh-tag.js 182 B
./react/rh-tile/rh-tile-group.js 183 B
./react/rh-tile/rh-tile.js 194 B
./react/rh-timestamp/rh-timestamp.js 176 B
./react/rh-tooltip/rh-tooltip.js 175 B
./react/rh-video-embed/rh-video-embed.js 227 B
./uxdot/uxdot-best-practice.js 742 B
./uxdot/uxdot-copy-button.js 1.2 kB
./uxdot/uxdot-copy-permalink.js 1.1 kB
./uxdot/uxdot-example.js 1.17 kB
./uxdot/uxdot-feedback.js 727 B
./uxdot/uxdot-header.js 1.07 kB
./uxdot/uxdot-hero.js 679 B
./uxdot/uxdot-installation-tabs.js 675 B
./uxdot/uxdot-masthead.js 809 B
./uxdot/uxdot-pattern-ssr-controller-client.js 604 B
./uxdot/uxdot-pattern-ssr-controller-server.js 1.68 kB
./uxdot/uxdot-pattern-ssr-controller.js 213 B
./uxdot/uxdot-pattern.js 2.12 kB
./uxdot/uxdot-repo-status-checklist.js 1.16 kB
./uxdot/uxdot-repo-status-list.js 1.07 kB
./uxdot/uxdot-repo-status-table.js 782 B
./uxdot/uxdot-repo.js 1.17 kB
./uxdot/uxdot-search.js 2.39 kB
./uxdot/uxdot-sidenav.js 2.67 kB
./uxdot/uxdot-spacer-tokens-table.js 2.45 kB
./uxdot/uxdot-toc.js 1.13 kB

compressed-size-action

@adamjohnson adamjohnson marked this pull request as ready for review December 6, 2024 21:08
@bennypowers bennypowers changed the title feat(dialog): use native HTML dialog element v2 feat(dialog): use native HTML dialog element Dec 9, 2024
Copy link
Collaborator

@marionnegp marionnegp left a comment

Choose a reason for hiding this comment

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

  • The close button's target looks pretty large. Can we use --rh-length-xl for the width and height of the touch target?
    Screenshot 2024-12-09 at 12 35 46 PM

  • Can the slots use this spacing?

  • Is there a way to keep the close button fixed if the content has to scroll?
    Screenshot 2024-12-09 at 3 04 59 PM

  • This comment might need to go back to design for a future feature update, but the close button isn't visible in the video dialog demo. (I can make an issue if design needs to tackle dark theme to fix this.)
    Screenshot 2024-12-09 at 3 05 40 PM

.changeset/loud-coins-shake.md Outdated Show resolved Hide resolved
elements/rh-dialog/demo/rh-dialog.html Outdated Show resolved Hide resolved
elements/rh-dialog/demo/no-headings.html Outdated Show resolved Hide resolved
elements/rh-dialog/demo/rh-dialog.html Outdated Show resolved Hide resolved
elements/rh-dialog/docs/40-accessibility.md Outdated Show resolved Hide resolved
elements/rh-dialog/rh-dialog.css Outdated Show resolved Hide resolved
elements/rh-dialog/rh-dialog.css Show resolved Hide resolved
elements/rh-dialog/rh-dialog.ts Show resolved Hide resolved
elements/rh-dialog/rh-dialog.ts Outdated Show resolved Hide resolved
elements/rh-dialog/rh-dialog.ts Outdated Show resolved Hide resolved
@hellogreg hellogreg linked an issue Dec 12, 2024 that may be closed by this pull request
Copy link
Collaborator

@marionnegp marionnegp left a comment

Choose a reason for hiding this comment

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

The space between the header and the body gets lost once content is able to scroll. Can dialog retain the 16px (maybe as padding)?
Screenshot 2024-12-18 at 10 26 23 AM

Copy link
Collaborator

@marionnegp marionnegp left a comment

Choose a reason for hiding this comment

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

The header seems to be overlapping the body text a little bit now. 😬 Sorry for the back and forth!
Screenshot 2024-12-18 at 11 54 26 AM

Copy link
Collaborator

@zeroedin zeroedin left a comment

Choose a reason for hiding this comment

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

Let's get triggering modals

Copy link
Member

@bennypowers bennypowers left a comment

Choose a reason for hiding this comment

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

Last few changes then we'll be ready to rock

elements/rh-dialog/demo/no-headings.html Outdated Show resolved Hide resolved
align-items: center;
justify-content: center;
z-index: 500;
.visually-hidden {
Copy link
Member

Choose a reason for hiding this comment

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

Note

Not relevant to this PR, and please don't commit it to this branch, rather a separate PR.

I think it's time to move this and the previous rule into a shared stylesheet module, which would get adopted (via the static styles field) into every element.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could you expand on this how you'd recommend implementing this?

  • Are you suggesting using CSS module scripts (limited browser support)?
  • Would this go in RHDS? eg: elements/shared/styles/visually-hidden.css
  • Would it go in pfe-tools? eg @patternfly/pfe-tools/shared/styles/visually-hidden.css

Happy to get this going with some direction. TIA!


`<rh-dialog>`: Dialog now uses the native HTML `<dialog>` element internally.

Note: the `overlay` CSS shadow part is now deprecated in favor of the `--rh-dialog-backdrop-background-color` CSS custom property.
Copy link
Member

Choose a reason for hiding this comment

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

does the part still work? if not, this will need a major version bump

Suggested change
Note: the `overlay` CSS shadow part is now deprecated in favor of the `--rh-dialog-backdrop-background-color` CSS custom property.
Note: the `overlay` CSS shadow part is now deprecated in favor of the `--rh-dialog-backdrop-background-color` CSS custom property. It will still work, but you can expect the `overlay` part to be removed in a future version

Also, please confirm @coreyvickery that this deprecation aligns with design expectations: namely that in future versions the only customizable aspect of the backdrop will be its color (including transparency) - and that the existing ability to customize any css property for the backdrop should be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

does the overlay part still work?

Current version of overlay on uxdot is the overlay/backdrop of the dialog.

This PR's version keeps the overlay <div> and many of the styles (lines 146-149 in rh-dialog.ts and lines 35-44 in rh-dialog.css).

The only change is overlay is a transparent <div> overlaying the contents of the page. It's invisible to the user and customizable via the existing CSS part—should a user want to do that.

With this PR's upgrade to the native <dialog> element, the native ::backdrop property is being used alongside a customizable CSS variable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added Benny's note about removing overlay in a future version in 34d7598.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Paging Mr. @coreyvickery. 😇

See Benny's questions about overlay/backdrop and --offset vars below.

block-size: 100%;
content: '';
inline-size: 100%;
inset-block-start: calc(-1 * var(--offset-top));
Copy link
Member

Choose a reason for hiding this comment

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

--offset-top should either be --_offset-top or --rh-dialog-offset-block-start, depending on whether @coreyvickery intends for the offset to be user-customizable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, the following ("public") variables currently exist on uxdot and are in production—albeit not documented:

--offset
--offset-top
--offset-right

That leaves us with a decision:

  1. Do we change these variables as suggested?
    • A breaking change
  2. Or, do we leave these variables as is (and possibly document them)?

Copy link
Member

Choose a reason for hiding this comment

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

I think we need a patch changeset but one that clarifies that these names were always supposed to be private. WDYT @zeroedin? cc @zhawkins @OneEightyFirst

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with @bennypowers here; if undocumented, that tells me the intention from the start was that they were supposed to be private, and we could likely get away with a patch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we wanted to be super conservative, the other option might be to do something like:

#selector {
  /* @deprecated: --offset-top and will be removed in a future release */
  margin-block-start: var(--offset-top, var(--_offset-top)); 👈 
}

elements/rh-dialog/rh-dialog.css Show resolved Hide resolved
elements/rh-dialog/rh-dialog.css Show resolved Hide resolved
elements/rh-dialog/rh-dialog.ts Outdated Show resolved Hide resolved
elements/rh-dialog/rh-dialog.ts Outdated Show resolved Hide resolved
elements/rh-dialog/rh-dialog.ts Outdated Show resolved Hide resolved
elements/rh-dialog/rh-dialog.ts Outdated Show resolved Hide resolved
@adamjohnson adamjohnson changed the base branch from main to staging/cubone January 7, 2025 15:44
@marionnegp marionnegp self-assigned this Jan 8, 2025
@marionnegp
Copy link
Collaborator

I'll be making dialog docs updates in this branch/PR this week! Please don't merge before they're done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Review 🔍
Development

Successfully merging this pull request may close these issues.

[feat] <rh-dialog> dark theme [feat] <rh-dialog>: switch to native <dialog> element
4 participants