From fd2759206dcee20d0118268eea780783189d32e0 Mon Sep 17 00:00:00 2001 From: Anna Dabrowska Date: Mon, 14 Aug 2023 19:42:15 +0200 Subject: [PATCH] Restore stickiness of the menu bar lost in c398821008dbb8c42204091a7c873b84ff486710 because templates have conflicting overflow in CSS --- script/main.js | 14 ++++++++++++++ style.less | 2 -- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/script/main.js b/script/main.js index fd824ddf..e204d565 100644 --- a/script/main.js +++ b/script/main.js @@ -47,6 +47,20 @@ window.Prosemirror.enableProsemirror = function enableProsemirror() { nodeViews: getNodeViews(), }); window.view = view; + + // sticky menubar + jQuery(window).on('scroll.prosemirror_menu', () => { + const $container = jQuery('#prosemirror__editor'); + const $menuBar = $container.find('.menubar'); + const docViewTop = jQuery(window).scrollTop(); + const containerTop = $container.offset().top; + + if (docViewTop > containerTop) { + $menuBar.css('position', 'fixed'); + } else { + $menuBar.css('position', ''); + } + }); }; window.Prosemirror.destroyProsemirror = function destroyProsemirror() { diff --git a/style.less b/style.less index 4a70a8bc..de6466cd 100644 --- a/style.less +++ b/style.less @@ -85,8 +85,6 @@ display: block; .menubar { - position: sticky; - top: 0; // Users/Theme developers can override this to stick it below a sticky header margin-bottom: 0.5rem; border: @border-style; border-radius: @border-radius;