fix(scripts): Reorder bundle so bslib wins cascade ties against shiny.scss#2254
Closed
elnelson575 wants to merge 1 commit into
Closed
fix(scripts): Reorder bundle so bslib wins cascade ties against shiny.scss#2254elnelson575 wants to merge 1 commit into
elnelson575 wants to merge 1 commit into
Conversation
….scss `bs_full_theme()` in `scripts/_functions_sass.R` previously called `bs_bundle(theme, bslib = ..., shiny = ..., ...)`. bslib's `bs3compat` SCSS is baked into the `theme` argument, and `bs_bundle()` always stacks named layers on top of `theme`. This put bslib's overrides *before* R-shiny's `shiny.scss` rules in the compiled CSS, so any same-specificity tie went to shiny.scss by source order — the opposite of an R-shiny + bslib app, where R-shiny's `shiny.css` is loaded as its own `<link>` before bslib's bundle. The visible symptom: bslib PR #1308 (which lifts the specificity of the BS5 radio/checkbox label-margin rule to `.shiny-input-container .shiny-input-{kind}`) fixed vertical groups in py-shiny but inline groups still got the `-1px` from shiny.scss's `.shiny-input-{kind}.shiny-input-container-inline` rule, which ties at 0-3-1 and was emitted later in the file. Fix: drop down from `bs_bundle()` to `sass::sass_bundle()` so the theme can appear after a user layer, list `shiny` first and `theme` second, then reapply `class(theme)` to keep the bs_theme identity (mirrors `bs_bundle()`'s own implementation). The only same-specificity, same-element conflict between bs3compat and shiny.scss in BS5 mode is the radio/checkbox label-margin rule; no other styles change behavior under the reorder. Depends on rstudio/bslib#1308 for the visible fix.
This was referenced May 21, 2026
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.
Summary
Reorder layers in
bs_full_theme()so R-shiny'sshiny.scssemits before bslib's bs3compat in the compiledbootstrap.min.css. This matches the R-shiny + bslib head order and lets bslib's bs3compat overrides win cascade ties.bs_bundle()requiresthemefirst, so drop down tosass::sass_bundle()and reapply thebs_themeclass (mirroringbs_bundle()'s own implementation).Why
Inside py-shiny's combined bundle, bslib bs3compat sat at byte ~278k and shiny.scss at ~360k. Any 0-3-1 ↔ 0-3-1 specificity tie went to shiny.scss by source order — the opposite of R-shiny + bslib, where R-shiny loads its own
shiny.css<link>before bslib's bundle.Concrete symptom: bslib PR rstudio/bslib#1308 lifts the BS5 radio/checkbox label-margin rule to
.shiny-input-container.shiny-input-{kind}(0-3-1). That beat shiny.scss's base-10pxrule (0-2-1) for vertical groups, but tied shiny.scss's.shiny-input-container-inlinerule (0-3-1) and lost on source order for inline groups.Ordering with related PRs
Prerequisite for #2246. The script change must land before
make upgrade-html-depsis re-run, otherwise the regeneratedbootstrap.min.csskeeps the old layer order. Suggested sequence:make upgrade-html-depson chore: Upgrade bslib to 0.11.0 and Bootstrap to 5.3.8, add brite theme #2246's branch, then merge chore: Upgrade bslib to 0.11.0 and Bootstrap to 5.3.8, add brite theme #2246By itself this PR produces no compiled-output diff.
Collateral-damage audit
The only same-specificity, same-element conflict between bs3compat and shiny.scss in BS5 mode is the radio/checkbox label-margin rule. Other bs3compat rules (
.well,.help-text,.glyphicon,.navbar-*,.nav-tabs > li,.dropdown-menu > li,pre.shiny-code,.float-left/right, etc.) target selectors shiny.scss does not style. shiny.scss's.radio/.checkboxusages are prefixed with.qt5(different scope). bs3compat's.radio/.checkboxstyling is wrapped in@if \$bootstrap-version == 4and doesn't compile for BS5.Net effect: only the inline radio/checkbox gap changes, and it changes to the value bslib PR #1308 intended.
Test plan
make upgrade-html-depsand confirm bslib bs3compat rules emit after shiny.scss rules in the regeneratedbootstrap.min.cssui.input_radio_buttons()/ui.input_checkbox_group()share the same label-to-options gap as the vertical variants