Skip to content

♿️(frontend) focus export modal on format select#2421

Merged
Ovgodd merged 1 commit into
mainfrom
fix/a11y-2343-first-focusble-element
Jun 23, 2026
Merged

♿️(frontend) focus export modal on format select#2421
Ovgodd merged 1 commit into
mainfrom
fix/a11y-2343-first-focusble-element

Conversation

@Ovgodd

@Ovgodd Ovgodd commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Purpose

Fix keyboard navigation when opening the document export modal. By placing the foczs on the first useful interactive element.

Proposal

  • Remove autoFocus from the Cancel button in ModalExport
  • Move initial focus to the format Select when the modal opens
  • Use requestAnimationFrame to ensure focus is applied after the modal is rendered in the DOM

@Ovgodd Ovgodd requested a review from AntoLC June 12, 2026 07:22
@Ovgodd Ovgodd self-assigned this Jun 12, 2026
@Ovgodd Ovgodd added bug Something isn't working accessibility triage labels Jun 12, 2026
@Ovgodd Ovgodd linked an issue Jun 12, 2026 that may be closed by this pull request
@Ovgodd Ovgodd force-pushed the fix/a11y-2343-first-focusble-element branch from 77e14f2 to 55b5088 Compare June 12, 2026 07:23
@Ovgodd Ovgodd moved this from Backlog to In review in LaSuite Docs A11y Jun 12, 2026
@Ovgodd Ovgodd marked this pull request as ready for review June 12, 2026 07:27
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 4.34 MB

📦 View Changed
Filename Size Change
apps/impress/out/_next/static/4d04ea3b/_buildManifest.js 672 B +672 B (new file) 🆕
apps/impress/out/_next/static/e6280761/_buildManifest.js 0 B -672 B (removed) 🏆

compressed-size-action

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 235a0dd4-5a2b-4f0d-9060-e9f3ef091dbf

📥 Commits

Reviewing files that changed from the base of the PR and between 34b623e and ddb8646.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx

Walkthrough

This PR adds automatic focus management to the export modal's format selector. The ModalExport component is enhanced with useEffect and useRef hooks to focus the format dropdown when the modal mounts. A useEffect schedules a requestAnimationFrame to locate and focus the selector's underlying button element, with cancelAnimationFrame cleanup on unmount. The format selector is wrapped in a Box with the ref to enable reliable element targeting, and the Cancel button's autoFocus attribute is removed to prevent competing focus behavior. The changelog documents this frontend improvement.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • AntoLC
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: improving accessibility by focusing the export modal on the format select element when opened.
Description check ✅ Passed The description is directly related to the changeset, explaining the accessibility improvement and listing the specific implementation steps taken.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/a11y-2343-first-focusble-element

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 markdownlint-cli2 (0.22.1)
CHANGELOG.md

markdownlint-cli2 v0.22.1 (markdownlint v0.40.0)
Error: Unable to use configuration file '/coderabbit-0.markdownlint-cli2.jsonc'; ENOENT: no such file or directory, open '/coderabbit-0.markdownlint-cli2.jsonc'
at throwForConfigurationFile (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:48:9)
at readOptionsOrConfig (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:169:5)
at async main (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:927:21)
at async file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2-bin.mjs:14:22 {
[cause]: Error: ENOENT: no such file or directory, open '/coderabbit-0.markdownlint-cli2.jsonc'
at async open (node:internal/fs/promises:640:25)
at async Object.readFile (node:internal/fs/promises:1287:14)
at async readOptionsOrConfig (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:141:17)
at async main (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:927:21)
at async file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2-bin.mjs:14:22 {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/coderabbit-0.markdownlint-cli2.jsonc'
}
}


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx`:
- Around line 70-78: The focus-selector in ModalExport's useEffect is too broad
and may hit unintended nested buttons; update the query inside the
requestAnimationFrame callback to only target the Select component via
selectRef.current?.querySelector<HTMLButtonElement>('[role="combobox"]') (keep
the existing requestAnimationFrame/cancelAnimationFrame logic and the useEffect
as-is) so only the format Select gains focus; locate this change in the
useEffect inside the ModalExport component where selectRef is used.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 449627ad-1dc0-42dc-bafa-43497f0630e4

📥 Commits

Reviewing files that changed from the base of the PR and between 4c3b17a and 55b5088.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx

Comment on lines +70 to +78
useEffect(() => {
const frameId = requestAnimationFrame(() => {
const button = selectRef.current?.querySelector<HTMLButtonElement>(
'button, [role="combobox"]',
);
button?.focus();
});
return () => cancelAnimationFrame(frameId);
}, []);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for Modal lifecycle props in Cunningham or similar focus patterns in the codebase

# Search for Modal usage with lifecycle callbacks
rg -n -C3 'from.*cunningham.*Modal' --type=tsx --type=ts

# Look for other focus management patterns after modal open
rg -n -C3 'requestAnimationFrame.*focus' --type=tsx --type=ts

Repository: suitenumerique/docs

Length of output: 119


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Inspect the exact focus effect in the target file
echo "=== ModalExport.tsx (lines ~50-95) ==="
nl -ba src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx | sed -n '45,105p'

# 2) Find how Cunningham Modal is imported/used in this repo (tsx/js)
echo "=== Cunningham Modal imports/usages ==="
rg -n --glob='*.tsx' --glob='*.ts' -C2 'from\s+["'\''].*cunningham-react.*Modal["'\'']' || true
rg -n --glob='*.tsx' --glob='*.ts' -C2 '\bModal\b' src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx || true

# 3) Look for common lifecycle props/handlers around Modal
echo "=== Modal lifecycle prop names in TS/TSX ==="
rg -n --glob='*.tsx' --glob='*.ts' -C2 '\b(onAfterOpen|onOpened|onOpen|onAfterClose|onClosed|onClose)\b' src/frontend/apps/impress/src/features/docs/doc-export/components || true
rg -n --glob='*.tsx' --glob='*.ts' -C2 '\b(onAfterOpen|onOpened|onOpen|onAfterClose|onClosed|onClose)\b' src/frontend/apps/impress/src || true

# 4) Check for other requestAnimationFrame + focus patterns in the repo
echo "=== requestAnimationFrame .* focus patterns ==="
rg -n --glob='*.tsx' --glob='*.ts' -C2 'requestAnimationFrame.*focus|focus.*requestAnimationFrame' src/frontend/apps/impress/src || true

# 5) Ensure we didn't miss other Cunningham Modal references elsewhere
echo "=== Any Cunningham Modal usage outside doc-export ==="
rg -n --glob='*.tsx' --glob='*.ts' -C2 'cunningham-react' src/frontend/apps/impress/src || true

Repository: suitenumerique/docs

Length of output: 163


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx"

# 1) Inspect the exact focus effect in the target file (with line numbers via awk)
echo "=== ModalExport.tsx (lines 50-105) ==="
awk 'NR>=45 && NR<=105 {printf "%6d  %s\n", NR, $0}' "$FILE" | sed -n '1,200p'

# 2) Find how Cunningham Modal is imported/used in this repo
echo "=== Cunningham Modal imports/usages (impress app) ==="
rg -n --glob='*.tsx' --glob='*.ts' -C2 'from\s+["'\''\`].*cunningham-react.*["'\''\`]' src/frontend/apps/impress/src || true

echo "=== Cunningham Modal usage in doc-export components ==="
rg -n --glob='*.tsx' --glob='*.ts' -C2 '\bModal\b' src/frontend/apps/impress/src/features/docs/doc-export/components || true

# 3) Look for common lifecycle prop names around Modal usage
echo "=== Modal lifecycle prop names (impress app) ==="
rg -n --glob='*.tsx' --glob='*.ts' -C2 '\b(onAfterOpen|onOpened|onOpen|onAfterClose|onClosed|onClose)\b' src/frontend/apps/impress/src || true

# 4) Check for other requestAnimationFrame + focus patterns in the repo
echo "=== requestAnimationFrame .* focus patterns (impress app) ==="
rg -n --glob='*.tsx' --glob='*.ts' -C2 'requestAnimationFrame.*focus|focus.*requestAnimationFrame' src/frontend/apps/impress/src || true

Repository: suitenumerique/docs

Length of output: 50509


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx"
DIR="src/frontend/apps/impress/src/features/docs/doc-export/components"

echo "=== ModalExport.tsx imports (top of file) ==="
awk 'NR>=1 && NR<=60 {printf "%6d  %s\n", NR, $0}' "$FILE"

echo "=== Find cunningham-react usage (impress app) ==="
rg -n --glob='*.ts' --glob='*.tsx' 'cunningham-react' src/frontend/apps/impress/src || true

echo "=== Search modal lifecycle prop names ==="
rg -n --glob='*.ts' --glob='*.tsx' '\bonAfterOpen\b|\bonOpened\b|\bonAfterClose\b|\bonClosed\b|\bonOpen\b|\bonClose\b' src/frontend/apps/impress/src/features || true

echo "=== requestAnimationFrame + focus patterns in doc-export/components ==="
rg -n --glob='*.ts' --glob='*.tsx' 'requestAnimationFrame\([^\)]*\).*focus|focus.*requestAnimationFrame' "$DIR" || true

Repository: suitenumerique/docs

Length of output: 27415


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx"

# Print the part where selectRef is assigned and the Select is rendered
awk 'NR>=60 && NR<=150 {printf "%6d  %s\n", NR, $0}' "$FILE"
awk 'NR>=200 && NR<=290 {printf "%6d  %s\n", NR, $0}' "$FILE"

Repository: suitenumerique/docs

Length of output: 6653


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx"

echo "=== Find selectRef usage ==="
rg -n --glob='*.tsx' 'selectRef' "$FILE"

echo "=== Show around the Select rendering ==="
rg -n --glob='*.tsx' '(<Select\b|role="combobox")' "$FILE"
# Print a couple sections around first select usage
LINE=$(rg -n '(<Select\b|role="combobox")' "$FILE" | head -n1 | cut -d: -f1)
START=$((LINE-25))
END=$((LINE+60))
awk -v s="$START" -v e="$END" 'NR>=s && NR<=e {printf "%6d  %s\n", NR, $0}' "$FILE"

Repository: suitenumerique/docs

Length of output: 3610


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx"

# Print around the selectRef attachment and the Select component
awk 'NR>=280 && NR<=360 {printf "%6d  %s\n", NR, $0}' "$FILE"

# Check for autoFocus usage in this file
echo "=== autoFocus in ModalExport.tsx ==="
rg -n --glob='*.tsx' '\bautoFocus\b' "$FILE" || true

Repository: suitenumerique/docs

Length of output: 1606


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for requestAnimationFrame-based focus anywhere in impress app
rg -n --glob='*.ts' --glob='*.tsx' 'requestAnimationFrame\([^)]*\).*focus|focus.*requestAnimationFrame' src/frontend/apps/impress/src || true

# Search for autoFocus usage (often used for deterministic initial focus)
rg -n --glob='*.ts' --glob='*.tsx' '\bautoFocus\b' src/frontend/apps/impress/src || true

# Search for useModal usage (may provide focus/restore helpers)
rg -n --glob='*.ts' --glob='*.tsx' '\buseModal\b' src/frontend/apps/impress/src/features || true

Repository: suitenumerique/docs

Length of output: 3594


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect a few modal components that use autoFocus/useModal/FocusScope for initial focus behavior
FILES=(
  "src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteToolBar/ModalConfirmDownloadUnsafe.tsx"
  "src/frontend/apps/impress/src/features/docs/doc-versioning/components/ModalSelectVersion.tsx"
  "src/frontend/apps/impress/src/features/docs/doc-management/components/ModalRemoveDoc.tsx"
  "src/frontend/apps/impress/src/features/docs/doc-presenter/components/PresenterOverlay.tsx"
  "src/frontend/apps/impress/src/components/modal/AlertModal.tsx"
)

for f in "${FILES[@]}"; do
  echo "===== $f ====="
  # Print relevant region around the first autoFocus occurrence
  line=$(rg -n --glob='*.tsx' 'autoFocus' "$f" | head -n1 | cut -d: -f1 || true)
  if [ -n "${line:-}" ]; then
    start=$((line-20))
    end=$((line+40))
    awk -v s="$start" -v e="$end" 'NR>=s && NR<=e {printf "%6d  %s\n", NR, $0}' "$f" | sed -n '1,200p'
  else
    # fallback: print top part
    awk 'NR>=1 && NR<=120 {printf "%6d  %s\n", NR, $0}' "$f" | sed -n '1,200p'
  fi
done

# Specifically inspect how useModal is used in DocMoveModal (focus restore patterns)
echo "===== DocMoveModal useModal snippet ====="
DOCMOV="src/frontend/apps/impress/src/features/docs/docs-grid/components/DocMoveModal.tsx"
awk 'NR>=60 && NR<=180 {printf "%6d  %s\n", NR, $0}' "$DOCMOV" | sed -n '1,220p'

Repository: suitenumerique/docs

Length of output: 14753


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find other code focusing a combobox/select inside modals
rg -n --glob='*.ts' --glob='*.tsx' '\[role="combobox"\]' src/frontend/apps/impress/src || true

# Look for the same focus-by-querySelector pattern
rg -n --glob='*.ts' --glob='*.tsx' 'querySelector<.*>\(.*role="combobox"|requestAnimationFrame\([^\)]*\)\s*=>\s*\{[^\}]*querySelector' src/frontend/apps/impress/src || true

# Look for requestAnimationFrame focusing something inside modals
rg -n --glob='*.ts' --glob='*.tsx' 'requestAnimationFrame\([^\)]*\).*\.focus\(\)' src/frontend/apps/impress/src || true

Repository: suitenumerique/docs

Length of output: 185


ModalExport focus timing: no Cunningham lifecycle hooks in-repo; RAF matches existing patterns.

  • No onAfterOpen/onOpened (or similar) Cunningham Modal lifecycle props are used anywhere in this codebase, so the focus timing can’t be improved by swapping to a supported hook here.
  • The requestAnimationFrame focus pattern is consistent with other modals in this repo (e.g., ModalRemoveDoc uses requestAnimationFrame because focus restoration from other components can race with autoFocus).

Minor hardening: since selectRef only wraps the format Select, tighten the selector to [role="combobox"] (instead of button, [role="combobox"]) to avoid focusing an unintended nested button.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx`
around lines 70 - 78, The focus-selector in ModalExport's useEffect is too broad
and may hit unintended nested buttons; update the query inside the
requestAnimationFrame callback to only target the Select component via
selectRef.current?.querySelector<HTMLButtonElement>('[role="combobox"]') (keep
the existing requestAnimationFrame/cancelAnimationFrame logic and the useEffect
as-is) so only the format Select gains focus; locate this change in the
useEffect inside the ModalExport component where selectRef is used.

@Ovgodd Ovgodd force-pushed the fix/a11y-2343-first-focusble-element branch 2 times, most recently from a301fd9 to 34b623e Compare June 23, 2026 10:17
Focus export modal on format select for ARIA dialog compliance
@Ovgodd Ovgodd force-pushed the fix/a11y-2343-first-focusble-element branch from 34b623e to ddb8646 Compare June 23, 2026 11:05
@Ovgodd Ovgodd merged commit ddb8646 into main Jun 23, 2026
41 checks passed
@Ovgodd Ovgodd deleted the fix/a11y-2343-first-focusble-element branch June 23, 2026 11:36
@github-project-automation github-project-automation Bot moved this from In review to Done in LaSuite Docs A11y Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility bug Something isn't working triage

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Export modal: focus positioned on "Cancel" button on opening

2 participants