Skip to content

feat: Add scroll containment for embedded plugins - #390

Closed
maximizeIT wants to merge 1 commit into
mainfrom
feat-scroll-containment
Closed

maximizeIT wants to merge 1 commit into
mainfrom
feat-scroll-containment

Conversation

@maximizeIT

Copy link
Copy Markdown
Contributor

Description

Adds scrollIntoViewContained(element, options) and installScrollContainment().

Element.scrollIntoView also scrolls the page around the plugin's iframe. When the Staffbase app shows a footer, that page scrolls too, so jumps inside a plugin (e.g. the glossary's letter index) move the page under the app header.

  • scrollIntoViewContained: same arguments as scrollIntoView, scrolls only inside the plugin document.
  • installScrollContainment: makes the native method do the same, only inside a frame. Returns a restore function.

How Has This Been Tested?

  • 72 unit tests, lint, build, size limit (6.7 kB of 8 kB).
  • On ccmaxdev with the footer on, the built bundle in live plugin frames (own plugin and a sandboxed third-party page): host page stays at scrollY 0, plugin scroll matches native.

Quick check in a plugin frame's console, after loading the UMD build:

window['plugins-client-sdk'].installScrollContainment();
document.querySelector('h2:last-of-type').scrollIntoView({ block: 'start' });

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Test plan:

Open a plugin on a branch with the intranet footer enabled, call the snippet above, and confirm the Staffbase page does not scroll.

Created with OpenCode; AI wrote most of this change.

Element.scrollIntoView also scrolls the page around the plugin iframe. With a footer configured that page scrolls, so jumps inside a plugin (e.g. letter anchors in the glossary) moved the host page under its header. scrollIntoViewContained scrolls only inside the plugin document; installScrollContainment makes the native method do the same.

Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: GitHub Copilot <copilot@noreply.github.com>
@maximizeIT maximizeIT added improvement Pull requests that improve an existing part of the product and removed improvement Pull requests that improve an existing part of the product labels Nov 20, 2026
@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size
src/main.js 6.54 KB (+18.61% 🔺)

@maximizeIT maximizeIT added the do not merge Pull requests that should not be merged label Nov 20, 2026
@maximizeIT maximizeIT closed this Nov 20, 2026
@maximizeIT
maximizeIT deleted the feat-scroll-containment branch November 20, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Pull requests that should not be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant