Skip to content

Commit e635c9d

Browse files
authored
Merge pull request #306 from moderntribe/feature/MOOSE-333-vertical-tabs-scroll-to-top
MOOSE-333: Scroll vertical tabs into view on mobile after selection
2 parents 4fc4259 + 90d916b commit e635c9d

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ item (Added, Changed, Depreciated, Removed, Fixed, Security).
66

77
## [2026.01]
88

9+
- Fixed: Vertical Tabs block now scrolls the selected tab into view on mobile, respecting reduced motion preferences. [MOOSE-333](https://moderntribe.atlassian.net/browse/MOOSE-333)
910
- Fixed: Removed top margin from spacer block
1011
- Added: Yoast Duplicate Post plugin v4.5 for easier content duplication in the editor.
1112
- Updated: Login logo styling

wp-content/themes/core/assets/js/utils/tabs.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,17 @@ const switchTabs = ( targetTabButton ) => {
194194
tabButton
195195
);
196196
} );
197+
198+
// On mobile, scroll the selected tab into view so the user doesn't have to scroll back up
199+
if ( config.isMobile && config.contentMergesOnMobile ) {
200+
const prefersReducedMotion = window.matchMedia(
201+
'(prefers-reduced-motion: reduce)'
202+
).matches;
203+
targetTabButton.scrollIntoView( {
204+
behavior: prefersReducedMotion ? 'auto' : 'smooth',
205+
block: 'start',
206+
} );
207+
}
197208
};
198209

199210
/**

wp-content/themes/core/blocks/tribe/vertical-tabs/style.pcss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
border-left: 3px solid var(--vertical-tabs-border-color);
4242
transition: var(--transition);
4343

44+
/* Account for sticky header when scrolling tab into view on mobile */
45+
@media (--mq-wp-small-max) {
46+
scroll-margin-top: calc(var(--masthead-mobile-height) + var(--spacer-20));
47+
}
48+
4449
&[aria-selected="true"],
4550
&.editor-is-selected {
4651
pointer-events: none;

0 commit comments

Comments
 (0)