Scope the theme's close button rules to the theme's own close button - #7796
Open
nlemoine wants to merge 1 commit into
Open
Scope the theme's close button rules to the theme's own close button#7796nlemoine wants to merge 1 commit into
nlemoine wants to merge 1 commit into
Conversation
Alert renders its dismiss button through Button, so it comes out as `btn btn-invisible btn-close`. The theme has five rules written for that button, in buttons.css and alerts.css, and all five are selected on `.btn-close` alone. So they also hit plain Bootstrap close buttons: modal headers, toasts, offcanvas. Those don't have the `--button-*` custom properties, only the `.btn` rule declares them, and they don't have the `.btn` layout that some of these rules exist to undo. Two of the five broke such a button. `.btn-close:hover` painted `background: var(--button-hover-bg, var(--button-bg))`. Both properties are missing there, so the declaration was invalid at computed-value time, `background` fell back to its initial longhands, and `background-image: none` wiped the glyph. Bootstrap draws that glyph as a data-URI background, so the button went empty on hover. `[data-bs-theme="dark"] .btn-close` reset `filter` to none. Fine for our own button, its glyph is a child <svg> in currentColor and inverting it would be wrong. On a plain one it cancelled `--bs-btn-close-filter`, and that filter is what turns Bootstrap's black glyph white. Black glyph on a dark surface. Scoping the five rules to `.btn.btn-close` leaves plain close buttons to Bootstrap. The two `background` declarations also become `background-color`. My guess is the color was the intent anyway, the transition-property right above says background-color.
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
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.
Two bugs, same cause, so I put them in one PR.
Alertrenders its dismiss button throughButton, so it comes out asbtn btn-invisible btn-close. The theme has five rules written for that button, inbuttons.cssandalerts.css. All five are selected on.btn-closealone. So they also hit plain Bootstrap close buttons: modal headers, toasts, offcanvas. Those don't have the--button-*custom properties (only the.btnrule declares them), and they don't have the.btnlayout that some of these rules exist to undo.Blank on hover,
buttons.css:Both properties are missing on a plain close button. The declaration is then invalid at computed-value time,
backgroundfalls back to its initial longhands, andbackground-image: nonewipes the glyph. Bootstrap draws that glyph as a data-URI background, so the button is just empty on hover.Black glyph in dark mode,
alerts.css:Fine for our own button, its glyph is a child
<svg>in currentColor, inverting it would be wrong. On a plain one it cancels--bs-btn-close-filter, and that filter is what turns Bootstrap's black glyph white. Black glyph on a dark background.Repro: drop
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>into a modal header on any EasyAdmin page. Hover it, glyph gone. Switch to dark, glyph black.The fix scopes the five rules to
.btn.btn-close, so plain close buttons are left to Bootstrap. I also switched the twobackgrounddeclarations tobackground-color. My guess is the color was the intent anyway, thetransition-propertyright above saysbackground-color. The shorthand would keep wiping the glyph even where the variables resolve, it just doesn't show there.Assets rebuilt with
make build-assets. Compiled diff inpublic/app.*.cssis those five rules and nothing else.