Skip to content

Commit 275d939

Browse files
authored
fix: hide conditionalPanel() on initial render to prevent flash (#4377)
* fix: hide conditionalPanel on initial render to prevent flash (#3505) conditionalPanel renders visible HTML, but the JS that evaluates the condition doesn't run until the WebSocket connects. This causes a brief flash of content that should be hidden. Fix by using CSS to hide `.shiny-panel-conditional` by default, and toggling a `--active` modifier class in JS when the condition is true. This also avoids jQuery's `.show()` setting `display: block`, which would conflict with BS5's `display: contents` pass-through rule. * `npm run build` (GitHub Actions) * Add NEWS entry for conditionalPanel flash fix (#3505) * Target [data-display-if] in CSS instead of .shiny-panel-conditional The JS targets all [data-display-if] elements, so the CSS should match. This ensures hand-crafted HTML with data-display-if (without the .shiny-panel-conditional class) also gets the hidden-by-default behavior. * Extract CSS class name into a single const * Rename CSS class to shiny-conditional--shown Drops "panel" since the class applies to any [data-display-if] element, not just conditionalPanel() output. Uses "shown" to mirror the existing show/shown/hide/hidden events and avoid confusion with Bootstrap's "active" class. * Use native classList API instead of jQuery for class toggling * Revert "Use native classList API instead of jQuery for class toggling" This reverts commit 2c077b9. * Move conditionalPanel news item into Improvements section --------- Co-authored-by: cpsievert <cpsievert@users.noreply.github.com>
1 parent 0bcf877 commit 275d939

9 files changed

Lines changed: 39 additions & 28 deletions

File tree

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
for code that needs to trigger theme clientdata refreshes after changing
1313
surrounding visual theme context. (#3682)
1414

15+
* `conditionalPanel()` no longer briefly flashes its contents on app start
16+
when the condition is initially `FALSE`. (#3505)
17+
1518
# shiny 1.13.0
1619

1720
## New features

inst/www/shared/shiny.js

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/www/shared/shiny.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/www/shared/shiny.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)