Scrollspy: replace global eval with scoped observer parity #11

Closed
opened 2026-06-23 19:00:30 +00:00 by mik-tf · 1 comment
Owner

Parent tracker: #1

Objective: replace the current global scrollspy implementation with scoped, multi-instance-safe behavior aligned with Bootstrap 5.3 Scrollspy.

Scope:

  • Remove reliance on shared window.__dioxus_scrollspy_active global state.
  • Use scoped observer/listener state per Scrollspy instance.
  • Support target scoping, custom scroll containers, root margin, thresholds, and offset compatibility where practical.
  • Ignore non-visible target elements.
  • Provide deterministic active-section selection when multiple sections intersect.
  • Support refresh behavior for dynamically added/removed sections.
  • Add optional smooth scroll if the typed API chooses to expose it.

Acceptance criteria:

  • Multiple Scrollspy instances do not interfere with each other.
  • E2E covers body scroll, custom scroll container, active transitions, and refresh/dynamic content behavior where feasible.
  • Existing offset callers have a compatibility path or documented migration.
  • Existing checks stay green.

Dependencies: parity spec issue.

Signed-by: mik-tf mik-tf@noreply.invalid

Parent tracker: https://forge.ourworld.tf/lhumina_code/dioxus-bootstrap-css/issues/1 Objective: replace the current global scrollspy implementation with scoped, multi-instance-safe behavior aligned with Bootstrap 5.3 Scrollspy. Scope: - Remove reliance on shared `window.__dioxus_scrollspy_active` global state. - Use scoped observer/listener state per Scrollspy instance. - Support target scoping, custom scroll containers, root margin, thresholds, and offset compatibility where practical. - Ignore non-visible target elements. - Provide deterministic active-section selection when multiple sections intersect. - Support refresh behavior for dynamically added/removed sections. - Add optional smooth scroll if the typed API chooses to expose it. Acceptance criteria: - Multiple Scrollspy instances do not interfere with each other. - E2E covers body scroll, custom scroll container, active transitions, and refresh/dynamic content behavior where feasible. - Existing `offset` callers have a compatibility path or documented migration. - Existing checks stay green. Dependencies: parity spec issue. Signed-by: mik-tf <mik-tf@noreply.invalid>
Author
Owner

Implemented Scrollspy parity in 3f3d0eca8d, with a follow-up CI clippy fix in 451361ec45.

Summary:

  • Replaced shared window.__dioxus_scrollspy_active state with scoped per-instance observer/listener state.
  • Added Bootstrap target semantics plus root, root_margin, threshold, refresh_key, smooth_scroll, and offset compatibility.
  • Added body and custom scroll-root support, non-visible section filtering, deterministic active-section selection, active link class updates, signal updates, MutationObserver refresh, and per-instance cleanup.
  • Updated showcase, parity/design docs, and crate-level examples.
  • Added E2E coverage for body scroll, custom scroll container isolation, and dynamic refresh.

Verification:

  • cargo fmt --all -- --check
  • cargo check --target wasm32-unknown-unknown -p dioxus-bootstrap-css
  • cargo check --target wasm32-unknown-unknown -p showcase
  • cargo test -p dioxus-bootstrap-css
  • cargo clippy --target wasm32-unknown-unknown -p dioxus-bootstrap-css -- -D warnings
  • cargo clippy --target wasm32-unknown-unknown -p showcase -- -D warnings
  • npm run test:migrate
  • npm run lint:bootstrap
  • npm run test:e2e -- --grep "scrollspy"
  • npm run test:e2e (58 passed)
  • Forge CI run 24 is green.

Signed-by: mik-tf mik-tf@noreply.invalid

Implemented Scrollspy parity in 3f3d0eca8d3ac1e31b7df0cc484ec3c069bbedf8, with a follow-up CI clippy fix in 451361ec455c9e22cec27216066eba2c6c464e60. Summary: - Replaced shared window.__dioxus_scrollspy_active state with scoped per-instance observer/listener state. - Added Bootstrap target semantics plus root, root_margin, threshold, refresh_key, smooth_scroll, and offset compatibility. - Added body and custom scroll-root support, non-visible section filtering, deterministic active-section selection, active link class updates, signal updates, MutationObserver refresh, and per-instance cleanup. - Updated showcase, parity/design docs, and crate-level examples. - Added E2E coverage for body scroll, custom scroll container isolation, and dynamic refresh. Verification: - cargo fmt --all -- --check - cargo check --target wasm32-unknown-unknown -p dioxus-bootstrap-css - cargo check --target wasm32-unknown-unknown -p showcase - cargo test -p dioxus-bootstrap-css - cargo clippy --target wasm32-unknown-unknown -p dioxus-bootstrap-css -- -D warnings - cargo clippy --target wasm32-unknown-unknown -p showcase -- -D warnings - npm run test:migrate - npm run lint:bootstrap - npm run test:e2e -- --grep "scrollspy" - npm run test:e2e (58 passed) - Forge CI run 24 is green. Signed-by: mik-tf <mik-tf@noreply.invalid>
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/dioxus-bootstrap-css#11
No description provided.