Closed (fixed)
Project:
BS Lib
Version:
2.0.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
12 Jan 2023 at 15:50 UTC
Updated:
19 May 2026 at 19:05 UTC
Jump to comment: Most recent
The bs_lib_scroll_to_top_block plugin and its companion JS/CSS carry legacy design decisions from the jQuery era and surface a few papercuts when used in a modern Drupal 11 site:
js/scroll-to-top.js depends on core/jquery and optionally core/jquery.ui.effects.core. Native window.scrollTo({ top: 0, behavior: 'smooth' }) plus scroll + resize listeners cover the full behavior without jQuery.prefers-reduced-motion support. jQuery's animate() ignores the user's motion preference. Users who opt into reduced motion still get the animated scroll.easing (swing / linear) only makes sense with jQuery UI. If we drop jQuery, the config field becomes meaningless.duration is a free-form textfield. Schema says integer but the form accepts any string. Should be #type=number with min / max / step.position: 'static' is a misleading option label. The CSS property position: static is unrelated to what this setting controls. Something like Inline (rendered where the block is placed) reads more clearly.offset: 0 is a hidden "always visible" shortcut. build() adds bs-lib-scroll-to-top--show at render time when offset == 0. Only has a visible effect in position: fixed and the branching is undocumented. Either drop it or make it an explicit "Always visible" checkbox.$this.click(...) is a deprecated jQuery shorthand. Moot if we go vanilla.text is wrapped in <span class="label"> so site builders can apply the hide-label utility to visually hide the label while keeping it for screen readers. The form description just says "Text of a scroll to top element." — people don't discover the .label wrapper without reading source.build() returns #type=link directly. Themes that want to change the markup (SVG icon, different structure) have to subclass the plugin or post-process render arrays. A bs-lib-scroll-to-top.html.twig template would be a cleaner extension point.Split into logical commits so each can be reviewed independently. Items ordered from lowest risk to biggest behavioral change.
duration to #type=number with #min, #step, #default_value, and a reasonable max.offset and offset_opacity to #type = number; update bs_lib.schema.yml from string to integer with a post_update casting existing values.text field description to mention the .label wrapper and the hide-label helper.position option labels; keep stored values as static / fixed for BC.bs_lib_scroll_to_top) with variables { attributes, link_attributes, label, url }.templates/bs-lib-scroll-to-top.html.twig rendering the default markup.BSLibScrollToTopBlock::build() to return a themed render array instead of #type=link.hook_theme() in bs_lib.module.js/scroll-to-top.js without jQuery. Use core/once for attach, window.scrollTo with behavior: 'smooth' / 'auto' branched on prefers-reduced-motion, passive scroll listener + requestAnimationFrame for the show/hide toggle, and IntersectionObserver on position_fixed_disable_element for the fixed → absolute toggle (more efficient and accurate than the current getBoundingClientRect() polling).easing config field; post_update removes it from existing blocks; schema removes it.core/jquery.ui.effects.core library dep.duration field but mark it deprecated (native smooth scroll doesn't expose a duration knob). Alternative: drop it too with a post_update — decide during review.--bs-lib-scroll-to-top-offset-x / -y custom properties in the module README.--bs-lib-scroll-to-top-offset-inline / -block logical-property aliases for LTR/RTL / writing-mode support.easing (and optionally duration). Ship a hook_post_update_NNNN() that loads each bs_lib_scroll_to_top_block, removes the deprecated keys, and saves.js/scroll-to-top.js will need to migrate; call this out in the CHANGELOG.easingposition: static on small / big screens; position: fixed with and without position_fixed_disable_element; offset: 0 replacement path; prefers-reduced-motion: reduce honored on click; RTL.README.md with all user-facing changes.Two prerequisite rounds have already landed on the 2.0.x branch:
--bs-lib-scroll-to-top-offset-x / -y / -z-index), with the consuming theme's wrapper rules scoped to small screens.css_class_wrapper setting routes classes onto the outer <div class="block …"> via #attributes, so visibility utilities like hide-size-big collapse the whole block instead of only the inner <a>. Composes with block_class.Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pivica commentedComment #3
pivica commentedComment #6
pivica commentedDone.