-
Notifications
You must be signed in to change notification settings - Fork 44
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
DialogPrimitive
- Fix issue with box-sizing
inheritance
#2442
Merged
Conversation
This file contains 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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
… and replaced with explicit overrides
didoo
force-pushed
the
3869-fix-dialog-primitive-box-sizing
branch
from
September 23, 2024 11:10
591db56
to
fc893b8
Compare
KristinLBradley
approved these changes
Sep 23, 2024
shleewhite
approved these changes
Sep 23, 2024
all: unset; // removes default dialog & inherited styles. Must be the first style to be applied | ||
// ----------- | ||
// override default `<dialog>` styles | ||
position: initial; |
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.
I like that we're being explicit about what we are overriding from <dialog>
, makes it easier to understand!
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📌 Summary
In #2211 I (specifically @didoo) have introduced a change to the
Modal/Flyout
components, to use a newly createdDialogPrimitive
that could be used as standalone component/primitive as well as sub-componentBecause of this, I decided to reset the default styles applied to the "root" element of the
DialogPrimitive
, which is a<dialog>
HTML element, using aall: unset
CSS rule, and then apply the desired styles atModal/Flyout
level (while sharing the common styles in theDialogPrimitive
CSS styles, declaring them just after theall: unset
reset:The change was described as "non-breaking" in the original PR.
Thanks to @aklkv raising the issue in a Slack thread, we've come to realize that this actually introduced a regression in the UI of the Modal in some of our components: depending on where the CSS reset for the
box-sizing
property was declared in the order of imports, some of the UI elements assumed abox-sizing: content-box
property (thanks to the*, *::before, *::after { box-sizing: inherit; }
rule) and with in some cases the padding applied to them was added to the height, causing them to blow up (see button in the screenshot below):We missed this detail, both in implementation as well as in review, because the HDS showcase the reset is declared after the import of the HDS components styles, so the
box-sizing
applied to<dialog>
is inherited from the<html>
element, which is set toborder-box
in the reset:while in Cloud UI is declared before the import of the CSS
🛠️ Detailed description
In this PR I have:
all: unset
declaration fromhds-dialog-primitive__wrapper
and replaced with explicit overridesNotice: there was a small visual regression in Percy but only in a mobile viewport and only for a use case, and was likely a fluke.
Preview: https://hds-showcase-git-3869-fix-dialog-primitive-box-sizing-hashicorp.vercel.app/components/modal
🔗 External links
Jira ticket: https://hashicorp.atlassian.net/browse/HDS-3869
👀 Component checklist
💬 Please consider using conventional comments when reviewing this PR.