Skip to content

Replace jQuery event-driven output info with per-output ResizeObserver/IntersectionObserver - #3682

Merged
cpsievert merged 17 commits into
mainfrom
resize-observer
Apr 28, 2026
Merged

cpsievert merged 17 commits into
mainfrom
resize-observer

Conversation

@cpsievert

@cpsievert cpsievert commented Aug 9, 2022 •

Copy link
Copy Markdown
Collaborator

Summary

  • Replaces the global jQuery shown/hidden/window.resize event listeners with per-output ResizeObserver and IntersectionObserver instances for detecting size changes and visibility transitions.
  • Adds a per-output MutationObserver (for theme-reporting outputs only) to replace the previous MutationObserver setup that was managed separately via maybeAddThemeObserver().
  • Consolidates sendImageSize, sendOutputHiddenState, and the theme-sending logic into a unified sendOutputInfo module with a single debounced send path.
  • Replaces the custom isHidden() DOM-walking function with the native el.checkVisibility() API (with a fallback for Safari < 17.4).
  • Adds cancel() to Debouncer and the debounce() utility so observer callbacks are properly cleaned up on unbind.
  • Removes the sendImageSize.ts module, the filterEventsByNamespace helper, jQuery event subscriptions for Bootstrap 3/2 shown/hidden events, and related jQuery event type declarations.

Motivation

The old approach required layout containers to fire jQuery shown.bs.* / hidden.bs.* events for Shiny to detect visibility and size changes. This worked for Bootstrap but broke in non-Bootstrap layouts, CSS-only transitions, and third-party components that don't emit these events. Native browser observers eliminate this coupling entirely.

Closes #3831

@cpsievert cpsievert changed the title Send relevant getCurrentOutputInfo() input values on element resize, mutation, or intersection Update getCurrentOutputInfo() on element resize or visibility change Aug 9, 2022
@cpsievert
cpsievert requested a review from jcheng5 August 9, 2022 17:30
@dvg-p4

This comment was marked as outdated.

@dvg-p4

dvg-p4 commented Sep 14, 2022

Copy link
Copy Markdown
Contributor

(it's needed because, if the output container is stretchy, the image won't know to shrink when the container shrinks since it's size is determined by the parent)

@cpsievert what does a "stretchy output container" look like? e.g. what's an example app that doesn't resize the image properly without that fbe9d24 code? (Want to make sure my PR #3683 isn't overlooking an edge case, and that it's compatible with this fix.)

Comment thread srcts/src/shiny/init.ts Resolved
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 <[email protected]>
…dling

- 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 <[email protected]>
@dvg-p4 dvg-p4 mentioned this pull request Apr 21, 2026
5 tasks

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

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.
The debounce() function already returns DebouncedFunction with a
required `cancel` property. The cast to an optional `cancel` weakened
type checking.

This comment was marked as resolved.

Wrap setTimeout callbacks with arrow functions so regular is resolved
at call time rather than captured when it may still be undefined.

This comment was marked as resolved.

@cpsievert
cpsievert merged commit e07298a into main Apr 28, 2026
16 checks passed
@cpsievert
cpsievert deleted the resize-observer branch April 28, 2026 14:41
elnelson575 pushed a commit that referenced this pull request May 7, 2026
…r/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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* Simplify observer setup: inline outputInfoObserver, consolidate cleanup, guard null IDs

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* 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 <[email protected]>
Co-authored-by: cpsievert <[email protected]>
elnelson575 pushed a commit that referenced this pull request May 7, 2026
…r/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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* Simplify observer setup: inline outputInfoObserver, consolidate cleanup, guard null IDs

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* 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 <[email protected]>
Co-authored-by: cpsievert <[email protected]>
elnelson575 pushed a commit that referenced this pull request May 7, 2026
The rebase with -X theirs kept an intermediate version of the #3682
ResizeObserver commit that was already superseded in main. Reset
srcts/src/shiny/index.ts and srcts/src/utils/index.ts to main's
versions and rebuild the JS bundles.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
cpsievert added a commit that referenced this pull request May 11, 2026
* feat: add data-shiny-disable-auto-enable attribute to opt out of download button auto-enable (#4119)

Frameworks like shinyjs, py-shiny, and custom JS can add
`data-shiny-disable-auto-enable` to a download button/link to prevent
Shiny from automatically removing the `disabled` class and
`aria-disabled` attribute on render. This provides a generic,
framework-agnostic opt-out for the auto-enable behavior introduced
in PR #4041.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Revised approach

* chore: rebuild shiny.js bundle

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* `devtools::document()` (GitHub Actions)

* `npm run build` (GitHub Actions)

* feat: rename autoUpdate to autoEnable, invert to data-ignore-update attr, block clicks on disabled download buttons

- Rename `autoUpdate` param to `autoEnable` in `downloadButton()`/`downloadLink()`
- Invert HTML attribute: `autoEnable=FALSE` now sets `data-ignore-update` (absent by default)
- Block click/auxclick events via preventDefault() when button has `disabled` class
- Update NEWS.md and add testthat tests for new attribute behavior

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* `devtools::document()` (GitHub Actions)

* `npm run build` (GitHub Actions)

* chore: add test snapshots and rebuild source maps

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix: block clicks on disabled download links via CSS and correct jQuery this binding

- Add `a.shiny-download-link.disabled { pointer-events: none }` to shiny.scss
  so disabled download links (not just btn-styled ones) block pointer events
- Fix click handler to use `this` instead of `e.currentTarget` — with jQuery
  delegated events, `e.currentTarget` is the document, not the matched element

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* chore: update comment in downloadlink.ts

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* `npm run build` (GitHub Actions)

* Update autoEnabled -> enabled

* tests: add unit and shinytest2 tests for downloadButton/Link enabled param

- Add missing `downloadLink starts disabled with correct attributes` unit test
- Add shinytest2 runtime tests covering all three `enabled` values for both
  downloadButton and downloadLink: initial state (auto-enable, stays disabled,
  starts enabled, shinyjs-disabled) and toggle on/off via a setEnabled custom
  message handler that mirrors shinyjs::enable()/disable()
- Clarify `enabled=FALSE` docs: the opt-out applies for the page lifetime via
  data-ignore-update, so renderValue never auto-enables regardless of runtime state
- Remove unreachable dead code in DownloadLinkOutputBinding.showProgress()

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Add to suggests

* `devtools::document()` (GitHub Actions)

* chore: fix review issues — add shinyjs to Suggests, correct docs, skip_on_cran

- Add shinyjs to DESCRIPTION Suggests (referenced in @PARAM and @Seealso)
- Add shinyjs::enable()/disable() to @Seealso
- Fix enabled="auto" doc: "non-NULL filename" was inaccurate; say "initialized the downloadHandler"
- Remove "(replacing autoEnable)" from NEWS — autoEnable was never public
- Add skip_on_cran() to shinytest2 browser test
- Fix trailing space in test app comment

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* chore: remove shinyjs from seealso (already linked inline in param docs)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Update showProgress method signature in DownloadLinkOutputBinding

* Fix formatting of DownloadLinkOutputBinding class

* `npm run build` (GitHub Actions)

* fix: use e.currentTarget instead of this in download link click handler

Cast to HTMLAnchorElement for precise typing of .id and .href.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix: revert showProgress and dead code cleanups per code review

Restore showProgress signature and return/e dead code to keep
the diff minimal per cpsievert's feedback.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* chore: update generated type declaration for showProgress revert

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Update DESCRIPTION

Co-authored-by: Barret Schloerke <[email protected]>

* refactor: address code review feedback

- Use auto_enable/enabled logical vars in downloadButton/downloadLink
  instead of string comparisons; drop redundant else NULL
- Share single AppDriver across all shinytest2 tests (faster, ~12s vs ~33s)
- Add skip_on_os() to restrict shinytest2 tests to mac
- Remove redundant Config/Needs/check entry now that shinytest2 is in Suggests

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix AppDriver setup

* fix comment

* fix: revert formatting in downloadButton signature, add auxclick comment

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* Simplify observer setup: inline outputInfoObserver, consolidate cleanup, guard null IDs

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* 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 <[email protected]>
Co-authored-by: cpsievert <[email protected]>

* `devtools::document()` (GitHub Actions)

* fix: address code review feedback

- Rename data-ignore-update to data-shiny-disable-auto-enable
- Separate auxclick handler from shiny:filedownload to preserve event semantics
- Move test-only deps (callr, devtools, httr, shinytest2) to Config/Needs/check

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix: apply data-shiny-disable-auto-enable to enabled=TRUE as well

When `enabled = TRUE`, the attribute was previously omitted. Now it is
included for both `enabled = TRUE` and `enabled = FALSE`, since the
attribute's purpose is to signal any non-auto state — not just the
disabled state.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* refactor: replace sendCustomMessage with renderUI in test app, use input_switch

Replace the custom setEnabled JS message handler with renderUI()-based
toggling, which exercises the actual Shiny rendering/re-binding code
path including renderValue re-firing on element replacement. Replace
actionButton toggles with bslib::input_switch for clearer intent.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* docs: convert shinyjs doc links to plain text, remove from Suggests

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* style: use braces for auto_enable if/else block

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* style: convert enabled to logical in one line, drop if/else block

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix: remove redundant auxclick handler

pointer-events:none CSS on disabled download links already blocks all
mouse interactions including middle-click, making the auxclick handler
unnecessary.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix: simplify enabled param to default \"auto\", validate with cli_abort

Replace match.arg coercion with explicit is.logical() check and
cli::cli_abort() for a cleaner signature and better error message.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix: move enabled param after icon in downloadButton signature

Per reviewer feedback (r3163231438).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* test: add shinytest2 browser tests for downloadButton/Link enabled param

- Add helper-shinytest2.R with shared skip_if_not_shinytest2() helper
- Add test-zzz-st2-download.R using AppDriver$new(generate_app) pattern
  with pkgload::load_all() to load the local dev package in subprocess
- Refactor test-downloadButton-shinytest2.R to use skip_if_not_shinytest2()

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* chore: regenerate plotPNG.Rd

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* chore: add shinyjs to Config/Needs/check

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* test: use shinyjs::disabled() in shinyjs test cases, explain subprocess loading

- Replace htmltools::tagAppendAttributes(class = "shinyjs-disabled") with
  shinyjs::disabled() in both test app and test-zzz-st2-download.R
- Add shinyjs::useShinyjs() to test app UIs
- Add comment explaining why pkgload::load_all() is called explicitly in
  generate_app (shinytest2 shims library() but those shims rely on shiny
  being available for shiny::runApp(); we load it directly to bootstrap)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* chore: trim generate_app comment

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* chore: fix generate_app comment (shim reason, not jQuery timing)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* test: remove redundant shinytest2 test and app

test-zzz-st2-download.R covers the same behavior via AppDriver$new(generate_app),
making the callr+URL approach in test-downloadButton-shinytest2.R unnecessary.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* chore: remove callr and httr from check deps (no longer used in tests)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* test: update shinyjs test descriptions to reflect actual mechanism

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix: switch shinytest2 test to callr+URL approach to avoid jQuery timing issue

AppDriver$new(fn) has the same timing issue as AppDriver$new(app_dir):
shinytest2's tracer injects before jQuery/Shiny are ready when the package
is devtools-loaded. We work around this by starting the app in a callr
subprocess, polling until ready, then connecting via URL.

Also restores callr and httr to Config/Needs/check and helper skip guard.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix: use callr+URL approach for shinytest2, switch to checkboxInput toggles

AppDriver$new(fn) has a timing race in the devtools-loaded context: it
navigates immediately after the port opens, before the app has finished
serving all static resources. For complex apps this causes shinyjs's inline
handlers to fire before shiny.min.js loads, leaving Shiny undefined.

The callr+HTTP polling approach avoids this by waiting for a successful
GET before connecting AppDriver to the already-running app.

bslib::input_switch is replaced with checkboxInput for the toggle controls.
bslib adds a <script type="module"> (web-components.min.js) which is deferred
and also contributes to the resource-loading race in this context.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Fixing testing issue

* Update helper

* chore: reset index.ts files to main and rebuild JS

The rebase with -X theirs kept an intermediate version of the #3682
ResizeObserver commit that was already superseded in main. Reset
srcts/src/shiny/index.ts and srcts/src/utils/index.ts to main's
versions and rebuild the JS bundles.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* `devtools::document()` (GitHub Actions)

* Update docs and tests

* chore: reset unrelated Rd files to main

A GitHub Actions devtools::document() commit in the branch regenerated
all Rd files, adding noise to the PR diff. Reset all Rd files not
related to this feature (downloadButton/downloadLink) back to main.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* chore: clean up DESCRIPTION and NEWS noise from rebase

- Remove devtools from Config/Needs/check (not actually used in tests)
- Restore RoxygenNote: 7.3.3 and remove Config/roxygen2/version added
  by GitHub Actions devtools::document() commit
- Restore three NEWS bullet points dropped by -X theirs rebase

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* chore: restore Roxygen/RoxygenNote field order in DESCRIPTION

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* refactor: use tagGetAttribute in tests, update NEWS wording

- Replace regex expect_match/expect_no_match with htmltools::tagGetAttribute()
  for more precise attribute assertions
- Update NEWS entry to cpsievert's suggested wording

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix: guard empty href clicks and skip if shinyjs not installed

- Prevent early clicks on enabled=TRUE buttons before renderValue sets
  the URL (href="" would otherwise navigate to the current page)
- Add skip_if_not_installed("shinyjs") to skip_if_not_shinytest2() so
  tests skip cleanly in envs where shinyjs is not available

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* `devtools::document()` (GitHub Actions)

* chore: revert GitHub Actions devtools::document() noise in DESCRIPTION

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* chore: reset unrelated Rd files to main (GitHub Actions noise)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* refactor: move shinyjs skip guard to test file that uses it

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* `devtools::document()` (GitHub Actions)

* chore: reset GitHub Actions devtools::document() noise

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* `devtools::document()` (GitHub Actions)

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* Fix R CMD check warning for unstated test dependencies

Move shinytest2 to Suggests; access shinyjs indirectly via
getFromNamespace() to avoid the static pattern scanner.

* `usethis::use_tidy_description()` (GitHub Actions)

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Co-authored-by: elnelson575 <[email protected]>
Co-authored-by: Barret Schloerke <[email protected]>
Co-authored-by: Carson Sievert <[email protected]>
Co-authored-by: cpsievert <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: cpsievert <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
cpsievert added a commit to posit-dev/querychat that referenced this pull request Sep 10, 2026
Shiny 1.14.0 (on CRAN since 2026-06-21) replaced jQuery/Bootstrap
event-driven output visibility tracking with per-output
ResizeObserver/IntersectionObserver (rstudio/shiny#3682, #4388), which
handles shinychat's drawer toggling the hidden attribute natively.
The jQuery-based MutationObserver shim in querychat.js is no longer
needed on either side (py-shiny tracked visibility itself already).
cpsievert added a commit to posit-dev/querychat that referenced this pull request Sep 10, 2026
Shiny 1.14.0 (on CRAN since 2026-06-21) replaced jQuery/Bootstrap
event-driven output visibility tracking with per-output
ResizeObserver/IntersectionObserver (rstudio/shiny#3682, #4388), which
handles shinychat's drawer toggling the hidden attribute natively.
The jQuery-based MutationObserver shim in querychat.js is no longer
needed on either side (py-shiny tracked visibility itself already).
cpsievert added a commit to posit-dev/querychat that referenced this pull request Sep 10, 2026
Shiny 1.14.0 (on CRAN since 2026-06-21) replaced jQuery/Bootstrap
event-driven output visibility tracking with per-output
ResizeObserver/IntersectionObserver (rstudio/shiny#3682, #4388), which
handles shinychat's drawer toggling the hidden attribute natively.
The jQuery-based MutationObserver shim in querychat.js is no longer
needed on either side (py-shiny tracked visibility itself already).
cpsievert added a commit to posit-dev/querychat that referenced this pull request Sep 10, 2026
…293)

* feat(py): prototype app() on page() layout with auto-opening data drawer

Rebuild QueryChat.app()'s UI on the shinychat page_chat() layout (via
.page()) instead of page_sidebar. The SQL editor and data table cards
move into a chat_drawer(open=False), and a reactive effect in the
generated server auto-opens the drawer (chat.drawer.show()) whenever a
query lands on the active table.

ServerValues gains shinychat_chat (None in stub sessions) so host apps
can drive chat-level UI like the drawer controller.

Prototype only: R port, mobile auto-open behavior, and drawer sizing
are still open questions.

* docs(py): add drawer-layout smoke-test example app

* docs(py): fix run instructions to use project venv python

* feat(r): port app_obj() to page() layout with auto-opening data drawer

Mirror of the Python prototype: $app_obj()/$app() now build on
$page() (shinychat::page_chat()) instead of bslib::page_sidebar. The
SQL editor and DT cards move into shinychat::chat_drawer(open = FALSE),
and a server-side observer calls chat_drawer_show() when a query lands
on the active table. Busy indicators and the gadget close button ride
in the page_chat() footer slot (page_chat owns the whole document).

Also fixes a real bug this surfaced: R Shiny only re-scans output
visibility on bindAll/unbindAll or jQuery shown/hidden events, so
outputs inside an initially-closed drawer stayed suspended server-side
forever. querychat.js now watches the drawer's hidden attribute and
triggers the shown/hidden events Shiny listens for (jQuery-guarded;
py-shiny tracks visibility itself). Worth an upstream shinychat fix.

- DESCRIPTION bumps shinychat to >= 0.5.0 (page_chat/drawer API)
- Adds test-QueryChat coverage for the new app UI structure
- Adds inst/examples-shiny/13-app-drawer smoke-test app

* require shiny >= 1.14.0 and drop drawer visibility shim

Shiny 1.14.0 (on CRAN since 2026-06-21) replaced jQuery/Bootstrap
event-driven output visibility tracking with per-output
ResizeObserver/IntersectionObserver (rstudio/shiny#3682, #4388), which
handles shinychat's drawer toggling the hidden attribute natively.
The jQuery-based MutationObserver shim in querychat.js is no longer
needed on either side (py-shiny tracked visibility itself already).

* style(py): fix docstring formatting lint in drawer app test

* docs: drop drawer smoke examples; NEWS/CHANGELOG for chat-first app()

The 13-app-drawer examples were smoke-test checklists rather than
instructive examples. Also drops the standalone NEWS bullet for the
shiny >= 1.14.0 requirement and adds chat-first app() entries to both
NEWS.md and CHANGELOG.md.

* chore(py): restore querychat.js to base (shim removal left only newline diff)

* refactor(r): drop redundant comment in app_obj() ui

Re-applies web edit e0faf04 that was clobbered by the history-rewrite
force push.

* refactor(py): rename ServerValues.shinychat_chat to chat

Also drops the shiny >= 1.14.0 pin from DESCRIPTION -- it moves down
the stack to chat-footer-extras (#292).

* fix: restore pyright ignore on namespace_context import; align shinychat skip version

- The drawer branch's older _shiny.py content had clobbered
  page-method's pyright: ignore[reportPrivateImportUsage] on the
  namespace_context import, failing make py-check-types in CI.
- Copilot: () tests skipped on shinychat >= 0.4.0.9000, but
  DESCRIPTION requires >= 0.5.0.

* test(py): open data drawer in e2e fixtures for qc.app()-based apps

app() now starts with the data drawer closed (it auto-opens when a
query lands), so fixtures that waited for a visible table on page load
timed out. Add an open_data_drawer() helper that clicks the drawer
trigger before waiting for the table.

* refactor: demote SQL view to a footer control, tame drawer width

Makes the data table the drawer's primary content and tucks the SQL
editor behind a "Show Query" toggle in its footer, mirroring the
existing ggSQL show/hide pattern used by the Visualize tool. Also
replaces the drawer's fixed 720px width with a clamp-based policy
(matching the chat container's own width formula) so it no longer
dominates mid-size viewports.

* feat: give the drawer a real title and on-demand access to all tables

The drawer previously just said "Drawer" and only ever showed the
table the chat most recently touched, with no way to look at the
others. Now it's titled "Data Sources", and when more than one table
is registered, a fully static accordion below the pinned "active
table" card gives on-demand access to every table's own data grid and
read-only SQL query -- with a small badge marking which one the chat
is currently focused on.

Single-table apps are unaffected (no accordion, same pinned card as
before).

* test(py): reveal SQL query section before asserting on sql_editor in e2e tests

The data drawer's SQL panel moved behind a "Show Query" footer toggle;
Shiny suspends rendering of outputs inside hidden containers, so the
sql_editor code editor never mounted in the DOM for tests that checked
its value without expanding the section first.

* Update pkg-r/DESCRIPTION

* test(py): retry drawer-trigger click in e2e open_data_drawer

On slow CI runners the first click can land before shinychat's React
client has attached its handler, silently swallowing it; every
app()-based e2e test then timed out waiting for the drawer's table.
Retry the click until the drawer is actually open (and don't click at
all if it auto-opened already).

* docs(py): correct changelog -- app() is Core-only (Copilot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling el.trigger("hidden") in JavaScript doesn't work on elements that are being animated to be hidden

3 participants