UI Kit Modal causes jira:issuePanel to jump on open/close due to uncontrollable focus restoration

XMLWordPrintable

    • Severity 3 - Minor
    • Visual regression testing

      Issue Summary:

      When a Forge UI Kit (@forge/react) Modal is opened or closed inside a jira:issuePanel, the surrounding Jira issue view shifts vertically — inconsistently up or down. The jump occurs on both Save and Cancel, ruling out data changes or panel re-rendering as the cause.

      The root cause is Atlaskit's Modal component performing focus restoration to the triggering element on unmount. This fires a native browser scroll-into-view event on the real Jira page. Because UI Kit apps run in a sandboxed execution context with no access to the real DOM, there is currently no prop or API available to suppress or intercept this behaviour from app code.

      Steps to Reproduce

      1. Create a Forge UI Kit app (@forge/react) with a jira:issuePanel module
      2. Add a Modal component triggered by a button inside the panel (e.g. a row edit modal)
      3. Open the Jira issue view and expand the issue panel
      4. Click the button to open the modal
      5. Close the modal via Save, Cancel, or the close button

      Expected Results

      The issue panel and surrounding Jira issue view remain in their current scroll position after the modal closes. The layout does not shift or jump.

      Actual Results

      The Jira issue view shifts vertically (up or down, inconsistently) when the modal is opened or closed. The jump is reproducible on every modal open/close cycle regardless of whether form content changes.

      The behaviour has been confirmed as caused by Atlaskit's Modal focus restoration on unmount triggering a native scroll-into-view event at the platform level. App-side debugging confirmed that document.activeElement, window.scrollY, document.documentElement.scrollHeight, document.body.scrollHeight, and window.innerHeight all return 0 or inert stubs inside the UI Kit execution context — proving the app has no access to the real DOM and cannot intercept or suppress the platform-side focus event.

      No exception is thrown. This is a silent layout/scroll behaviour with no error signal.

      Workaround

      Replace the Modal with an inline expand or disclosure pattern within the panel itself (e.g. a collapsible section or conditional inline form rendered below the triggering row). With no modal mount/unmount cycle, no focus restoration event is triggered and the jump does not occur.

      Note: shouldScrollInViewport={false}{}, setTimeout delays on close, and HTMLElement.prototype.focus monkey-patching do not resolve the issue — they operate in the sandboxed execution context and cannot reach the real DOM that the platform renderer uses.

              Assignee:
              Unassigned
              Reporter:
              Damian Kleszcz
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: