Skip to content

Commit e07298a

Browse files
cpsievertclaude
andauthored
Replace jQuery event-driven output info with per-output ResizeObserver/IntersectionObserver (#3682)
* Use ResizeObserver/IntersectionObserver for per-output resize handling Replace the old window-resize + Bootstrap event listener approach with per-output ResizeObserver, IntersectionObserver, and MutationObserver. Each bound output now gets its own observers that handle resize, visibility, and theme changes independently, rather than relying on global window resize events and jQuery Bootstrap hooks. Also renames sendImageSize -> sendOutputInfo, simplifies bind.ts by removing sendOutputHiddenState/maybeAddThemeObserver from BindInputsCtx, and makes ImageOutputBinding.resize() actually set width/height on the img element. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix observer cleanup, zoom-aware sizing, and edge cases in resize handling - Disconnect ResizeObserver/IntersectionObserver/MutationObserver on unbind to prevent callbacks firing on stale elements - Restore getBoundingClientSizeBeforeZoom for size reporting to fix CSS zoom regression (see #4135) - Guard doTriggerResize against missing binding during teardown races - Fix visibleOutputs set to properly remove hidden outputs - Hoist observer setup out of doSendOutputInfo loop to avoid re-allocating closures on every call Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix pending output observer callbacks after unbind * Flush pending output info before input send * test and restore theme refresh for output observers * fix: avoid theme mutation observers for non-theme outputs * Replace custom isHidden() with native el.checkVisibility() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Simplify observer setup: inline outputInfoObserver, consolidate cleanup, guard null IDs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Revert image resize width/height attr setting The resize() method only needs to trigger the jQuery resize event for brush re-projection. Setting width/height attrs on the <img> just briefly stretched the stale plot before the server re-render replaced it, with no meaningful effect on behavior. * Restore image resize() to match main exactly The previous commit over-scoped the revert by changing the method signature. This restores the original signature from main. * Remove review doc * Skip doTriggerResize() during initial output info send * Add isVisible() fallback for browsers without checkVisibility() * `npm run build` (GitHub Actions) * Update NEWS.md * Remove unnecessary type cast in debounce cancel test The debounce() function already returns DebouncedFunction with a required `cancel` property. The cast to an optional `cancel` weakened type checking. * Defer sendOutputInfoFns.regular lookup to execution time Wrap setTimeout callbacks with arrow functions so regular is resolved at call time rather than captured when it may still be undefined. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: cpsievert <cpsievert@users.noreply.github.com>
1 parent 75a6371 commit e07298a

25 files changed

Lines changed: 692 additions & 627 deletions

NEWS.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
# shiny (development version)
22

3+
## Improvements
4+
5+
* Output resize/visibility detection now uses native browser observers
6+
(`ResizeObserver`, `IntersectionObserver`) instead of relying on jQuery
7+
`shown`/`hidden` events and `window.resize`. This makes Shiny's client-side
8+
output-info pipeline (image/plot sizing, hidden-state tracking, theme
9+
reporting) work automatically in any layout — including CSS-only show/hide,
10+
third-party tab components, and non-Bootstrap frameworks — without requiring
11+
custom event hooks. (#3682)
12+
313
# shiny 1.13.0
414

515
## New features
616

7-
* Shiny now supports interactive breakpoints when used with Ark (e.g. in Positron). (#4352)
17+
* Shiny now supports interactive breakpoints when used with Ark (e.g. in
18+
Positron). (#4352)
819

920
## Bug fixes and minor improvements
1021

11-
* Stack traces from render functions (e.g., `renderPlot()`, `renderDataTable()`) now hide internal Shiny rendering pipeline frames, making error messages cleaner and more focused on user code. (#4358)
22+
* Stack traces from render functions (e.g., `renderPlot()`, `renderDataTable()`)
23+
now hide internal Shiny rendering pipeline frames, making error messages
24+
cleaner and more focused on user code. (#4358)
1225

13-
* Fixed an issue with `actionLink()` that extended the link underline to whitespace around the text. (#4348)
26+
* Fixed an issue with `actionLink()` that extended the link underline to
27+
whitespace around the text. (#4348)
1428

1529

1630
# shiny 1.12.1

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default [{
4141
sourceType: "module",
4242

4343
parserOptions: {
44-
project: ["./tsconfig.json"],
44+
project: ["./tsconfig.eslint.json"],
4545
},
4646
},
4747

0 commit comments

Comments
 (0)