diff --git a/app/assets/javascripts/wikis/wikis.js b/app/assets/javascripts/wikis/wikis.js index 36b59307893fc758517c0a656f6e18f72a8a3610..938499bbca17ba6d01ee00938637dcf3d4028470 100644 --- a/app/assets/javascripts/wikis/wikis.js +++ b/app/assets/javascripts/wikis/wikis.js @@ -19,6 +19,18 @@ export default class Wikis { .querySelector('.js-sidebar-wiki-toggle-open') ?.addEventListener('click', this.expandSidebar.bind(this)); + const stickyElement = document.querySelector('.sidebar-container'); + const sentinel = document.querySelector('.sentinel'); + + const observer = new IntersectionObserver( + ([entry]) => { + stickyElement.classList.toggle('scrolled', !entry.isIntersecting); + }, + { threshold: [0] }, + ); + + observer.observe(sentinel); + // Store pages visbility in localStorage const pagesToggle = document.querySelector('.js-wiki-expand-pages-list'); if (pagesToggle) { diff --git a/app/assets/stylesheets/page_bundles/wiki.scss b/app/assets/stylesheets/page_bundles/wiki.scss index fe0ee52a16ee5e191b8a6c60dec593d57c74aebc..38342d85a794c87906bd464b03f7783508cb8c97 100644 --- a/app/assets/stylesheets/page_bundles/wiki.scss +++ b/app/assets/stylesheets/page_bundles/wiki.scss @@ -94,15 +94,34 @@ top: $calc-application-header-height; bottom: $calc-application-footer-height; z-index: 200; - overflow-y: auto; - overflow-x: hidden; + @apply gl-overflow-hidden; -webkit-overflow-scrolling: touch; width: $wiki-sidebar-inner-width; position: relative; + max-height: $calc-application-viewport-height; + @apply gl-flex; + @apply gl-flex-col; + + &.scrolled { + max-height: none; + } + @include gl-container-width-up(lg) { @include wiki-sidebar-container-lg-mod; } + + .blocks-container { + @apply gl-flex; + @apply gl-flex-col; + @apply gl-overflow-hidden; + @apply gl-grow; + } + + .wiki-pages-list-container { + @apply gl-grow; + @apply gl-overflow-y-auto; + } } li > .wiki-list { @@ -301,6 +320,7 @@ ul.wiki-pages-list.content-list { .wiki-sidebar { .sidebar-container { top: 0; + height: var(--panel-content-inner-height); /* This variable is subject to change */ } } } diff --git a/app/views/shared/wikis/_sidebar.html.haml b/app/views/shared/wikis/_sidebar.html.haml index f6c520756453f3f2c8552b2734b0e178bb38e004..fe9324d33cde887f5434975c1e30cbe83c6c5d26 100644 --- a/app/views/shared/wikis/_sidebar.html.haml +++ b/app/views/shared/wikis/_sidebar.html.haml @@ -4,6 +4,7 @@ %aside.wiki-sidebar.js-wiki-sidebar.sidebar-collapsed{ data: { "offset-top" => "50", "spy" => "affix" }, 'aria-label': _('Wiki') } .sidebar-container + .sentinel - if @sidebar_error.present? = render 'shared/alert_info', body: s_('Wiki|The sidebar failed to load. You can reload the page to try again.')