Commit 275d939
authored
fix: hide
* 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>conditionalPanel() on initial render to prevent flash (#4377)1 parent 0bcf877 commit 275d939
9 files changed
Lines changed: 39 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments