Skip to content

feat: ✨ Add ErrorBoundary on mobile#61

Open
wapec wants to merge 2 commits into
Euro-Office:mainfrom
wapec:feat/mobile-error-boundary
Open

feat: ✨ Add ErrorBoundary on mobile#61
wapec wants to merge 2 commits into
Euro-Office:mainfrom
wapec:feat/mobile-error-boundary

Conversation

@wapec
Copy link
Copy Markdown

@wapec wapec commented May 12, 2026

In editors display a framework7 dialog when ErrorBoundary catches a render error

How to test

Open any document type (.docx / .xlsx / .pptx / .vsdx) in the
mobile editor

Triggering a render error manually

Real render crashes are not deterministic, so use DevTools to invoke the
boundary's componentDidCatch directly.

  1. Open DevTools.

  2. In the Console tab, click the top dropdown at the top-left and
    switch context to the iframe whose URL ends in
    /web-apps/apps/<editor>/mobile/index.html.

  3. Paste and run:

    (function triggerErrorBoundary() {
      const app = document.getElementById('app');
      const key = Object.keys(app).find(k => k.startsWith('__reactContainer'));
      const root = app[key].stateNode.current;
      const find = (f) => {
        if (!f) return null;
        const n = f.stateNode;
        if (n && typeof n.componentDidCatch === 'function'
            && typeof f.type?.getDerivedStateFromError === 'function') return n;
        return find(f.child) || find(f.sibling);
      };
      const eb = find(root);
      if (!eb) throw new Error('ErrorBoundary not found');
      eb.componentDidCatch(new Error('Manual ErrorBoundary test from DevTools'));
    })();

The dialog should appear immediately. To test different error lengths,
replace the message string — e.g. new Error('Line1\nLine2\n…\nLine9')
to verify the multi-line truncation.

Test plan

Dialog appearance

  • A modal dialog appears with title "Error"
  • The error text is shown in monospace inside the dialog body
  • Exactly one button is rendered, labelled "OK"

Dialog behaviour

  • Tap OK: the editor closes (in a hosted iframe, this calls
    Common.Gateway.requestClose(), so the parent app — e.g. Nextcloud —
    receives the close signal; outside that, it falls back to /)
  • The dialog cannot be dismissed by tapping outside (modal)

Cross-editor coverage

  • documenteditor (.docx): dialog appears + single OK button works
  • spreadsheeteditor (.xlsx): same
  • presentationeditor (.pptx): same
  • visioeditor (.vsdx): same

Cross-theme rendering (Framework7 theme: 'auto')

  • iOS (UA = iPhone/iPad): centred title, rounded corners, OK
    centred below the body with a thin divider above it
  • Android / Material (UA = Pixel/other Android): left-aligned
    title, OK right-aligned in the dialog footer

Color / contrast (light vs dark mode)

  • Light system theme: dialog body is light, error text is #9b1c1c
    (deep red) — passes WCAG AAA against white
  • Dark system theme: body.theme-type-dark is set; dialog body is
    dark, error text switches to #ff6b6b — passes WCAG AA against the
    dark dialog background
  • Toggle OS dark mode while the editor is open: on next dialog open,
    the text color matches the active theme

Long error handling

  • Use a 9-line stack-trace payload (see the snippet note above)
  • Dialog body clamps to 7 lines with ellipsis
    (max-height 120 px)
  • Dialog does not grow to fill the screen

Sanity

  • No console errors appear besides the simulated one
  • After tapping OK there are no stuck modals or stale React state

Tested on

  • iOS Safari
    • documenteditor
    • spreadsheeteditor
    • presentationeditor
    • visioeditor
  • Android Chrome
    • documenteditor
    • spreadsheeteditor
    • presentationeditor
    • visioeditor

Screenshots

Dialog by platform — medium / long error in documenteditor

iOS Android
ios-medium android-medium
ios-long android-long

Dialog across editor types

spreadsheeteditor presentationeditor
cell slide

@wapec wapec force-pushed the feat/mobile-error-boundary branch from 0910e18 to a2e0758 Compare May 12, 2026 17:40
- Wrap each mobile editor's React root in a shared ErrorBoundary
- Show a framework7 dialog with the error and a single OK button
  that closes the editor (Common.Gateway.requestClose with a
  redirect fallback)

Signed-off-by: Bohdan Baranov <wapec@icloud.com>
@wapec wapec force-pushed the feat/mobile-error-boundary branch from a2e0758 to 20f6fa1 Compare May 20, 2026 05:34
@wapec wapec marked this pull request as ready for review May 20, 2026 21:38
@wapec wapec marked this pull request as draft May 28, 2026 11:49
@wapec
Copy link
Copy Markdown
Author

wapec commented May 28, 2026

Found a way to set a few style properties with global variables. Will update the code soon

- Add .error-dialog__code with monospace font and red text
- Clamp long stack traces to 7 lines (max-height 120px) with ellipsis

Signed-off-by: Bohdan Baranov <wapec@icloud.com>
@wapec wapec force-pushed the feat/mobile-error-boundary branch from 20f6fa1 to e9ce65f Compare May 29, 2026 05:46
@wapec wapec marked this pull request as ready for review May 29, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant