releaseselector: Fix page scroll on selector use
PATCH 1/1 releaseselector: Fix page scroll on selector use
When using selectors, all fields modified by the selector will be successively focused, inducing a potential page scroll. Save current scroll before applying the release selector and set back this scroll once the selector has been applied, setting back the page at the same position.
Signed-off-by Mathieu Dubois-Briand <[email protected]>
--- yocto_console_view/src/releaseselectorfield.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
yocto_console_view/src/releaseselectorfield.ts +17 -0
@@ -117,6 +117,13 @@ buildbotSetupPlugin((reg) => { * Apply values from the selected field selector */ async function applySelector(selector, selectorName) { + const modalBody = document.getElementsByClassName("modal-body")[0]; + let scrolltop = 0, scrollleft = 0; + if (modalBody) { + scrolltop = modalBody.scrollTop; + scrollleft = modalBody.scrollLeft; + } + for (let [field, value] of Object.entries(selector)) { const input = inputRefs.get('force-field-' + field); if (input && input.value != value) {
@@ -132,6 +139,16 @@ buildbotSetupPlugin((reg) => { const releaseSelector = inputRefs.get('force-field-branchselector'); releaseSelector.parentNode.previousSibling.textContent = selectorName; releaseSelector.focus(); + + /* Scroll back to the initial position. */ + if (modalBody) { + modalBody.scroll(scrollleft, scrolltop) + + setTimeout(() => { + modalBody.scroll(scrollleft, scrolltop); + }, 1); + + } } /*
---
base-commit: 62d5d77167a427d87516a6503137a3b2f264cfd5
change-id: 20250224-mathieu-release_selector_scroll-275dc6a2ac53
Best regards,
Signature · 1 line
Mathieu Dubois-Briand <[email protected]>