Skip to content

Show modal if there is no room for shortcuts - #732

Merged
lawsie merged 2 commits into
flipcomputing:mainfrom
lawsie:leave-room-or-go-modal
Jul 30, 2026
Merged

Show modal if there is no room for shortcuts#732
lawsie merged 2 commits into
flipcomputing:mainfrom
lawsie:leave-room-or-go-modal

Conversation

@lawsie

@lawsie lawsie commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

If there is no room below the canvas to show the contents of the keyboard or on-screen controls documentation tabs, show them in a modal instead. This previously happened in certain cases but didn't properly measure the height available. It should now go modal in all cases where it makes sense.

image

Also moved the tabs for these documentation panels under the gizmos on mobile landscape otherwise you couldn't even use them.

Screenshot 2026-07-30 164656

AI usage

Claude Haiku, Sonnet and Opus used for varying bits. Plans made and tested by me.

Summary by CodeRabbit

  • New Features

    • Info panels now automatically switch between docked and modal views on narrow screens and when available space is limited.
    • Shortcuts and player panels support improved modal presentation, focus handling, and keyboard navigation.
    • Landscape layouts display info-panel tabs beside the canvas for easier access.
  • Accessibility

    • Improved Escape-key focus restoration and arrow-key scrolling.
    • Added clearer modal labeling and translated close-button announcements.
  • Bug Fixes

    • Info-panel positioning now stays aligned with the canvas during resizing.
    • Prevented duplicate flock links in landscape layouts.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@lawsie, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ccb4b1aa-d5d9-48e0-8260-6a05c62df9ec

📥 Commits

Reviewing files that changed from the base of the PR and between 191fe53 and 3c25960.

📒 Files selected for processing (4)
  • accessibility/keyboardui.js
  • main/view.js
  • style.css
  • tests/keyboardui.test.js
📝 Walkthrough

Walkthrough

The change adds shared docked-versus-modal behavior for shortcuts and player info panels, based on narrow layout and available docked height. It updates modal accessibility handling, focus behavior, and resize observation, and positions landscape tabs alongside the canvas using a CSS width variable.

Changes

Responsive info panels

Layer / File(s) Summary
Shared modal presentation infrastructure
accessibility/keyboardui.js
Layout measurements, owner-aware tab registration, panel-specific accessibility identifiers, and resize observation now support shared modal transitions.
Shortcuts and player panel integration
accessibility/keyboardui.js
Both panels use the shared modal lifecycle; player panel Escape handling restores focus only when its tab is visible.
Canvas-aligned landscape tab layout
main/view.js, style.css
Canvas width is exposed through --canvas-width, and narrow landscape styles position info-panel tabs beside the canvas while hiding the panel body and duplicate flock link.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: tracygardner

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant InfoPanelTabs
  participant ShortcutsPanel
  participant ModalPanelBehaviour
  participant PanelDOM
  User->>InfoPanelTabs: activate panel tab
  InfoPanelTabs->>ShortcutsPanel: owner.toggle()
  ShortcutsPanel->>ModalPanelBehaviour: shouldBeModal()
  ModalPanelBehaviour-->>ShortcutsPanel: modal or docked state
  ShortcutsPanel->>PanelDOM: show panel and update accessibility attributes
  User->>PanelDOM: resize window or docked content
  PanelDOM->>ModalPanelBehaviour: resize notification
  ModalPanelBehaviour->>ShortcutsPanel: enterModal() or exitModal()
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: showing the shortcuts panel as a modal when there isn’t enough space.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
accessibility/keyboardui.js (1)

1277-1283: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Escape handler and hide() fight over focus.

hide() already restores previousFocus; this then re-focuses the tab button, so the restore is wasted work and the final target differs depending on layout. Consider letting hide() own focus restoration and dropping the extra focus call (or vice versa) so there's a single rule.

🤖 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 `@accessibility/keyboardui.js` around lines 1277 - 1283, Remove the tab-button
lookup and focus call from the Escape-key handler, allowing hide() to
exclusively restore previousFocus. Keep the existing preventDefault,
stopPropagation, and hide() behavior unchanged.
style.css (1)

1140-1150: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Magic 52px bottom-bar height.

bottom: calc(52px + …) silently depends on the bottom bar's height. A shared custom property (or --bottombar-height) would keep the tabs aligned if that bar changes.

🤖 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 `@style.css` around lines 1140 - 1150, Replace the hardcoded 52px offset in
aside#info-panel `#info-panel-tabs` with the shared bottom-bar height custom
property, preserving the safe-area inset calculation and existing positioning
behavior. Ensure the property is defined and reused from the bottom-bar styling
rather than introducing a duplicate height value.
🤖 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 `@accessibility/keyboardui.js`:
- Around line 774-785: Update the focus restoration in watchDockedSpace so
previousFocus is focused only when the current active element is actually inside
the modal or is the removed close-button control; otherwise preserve focus on
surviving panel controls. Clear or consume previousFocus after restoring focus
so a later hide() cannot refocus stale state.
- Around line 1268-1276: Update the ArrowUp/ArrowDown handling around the
scroller lookup so it targets the container that is actually scrolling: use the
modal panel’s active scroll container when the panel is reparented to
document.body, and retain `#info-panel-body` for docked mode. Preserve
preventDefault and the existing ±100 instant scroll behavior.

In `@main/view.js`:
- Around line 211-214: Update resizeCanvas() so the --canvas-width CSS variable
is set from canvas.getBoundingClientRect().right rather than newWidth, ensuring
fixed info-panel tabs anchor to the canvas’s actual right edge. Preserve the
existing rounding and CSS property publication.

---

Nitpick comments:
In `@accessibility/keyboardui.js`:
- Around line 1277-1283: Remove the tab-button lookup and focus call from the
Escape-key handler, allowing hide() to exclusively restore previousFocus. Keep
the existing preventDefault, stopPropagation, and hide() behavior unchanged.

In `@style.css`:
- Around line 1140-1150: Replace the hardcoded 52px offset in aside#info-panel
`#info-panel-tabs` with the shared bottom-bar height custom property, preserving
the safe-area inset calculation and existing positioning behavior. Ensure the
property is defined and reused from the bottom-bar styling rather than
introducing a duplicate height value.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5623ac2d-60fa-4ea1-bfb2-a380627e7f70

📥 Commits

Reviewing files that changed from the base of the PR and between fbfae19 and 191fe53.

📒 Files selected for processing (3)
  • accessibility/keyboardui.js
  • main/view.js
  • style.css

Comment thread accessibility/keyboardui.js
Comment thread accessibility/keyboardui.js Outdated
Comment thread main/view.js Outdated
@lawsie
lawsie merged commit e0d499b into flipcomputing:main Jul 30, 2026
3 checks passed
@lawsie
lawsie deleted the leave-room-or-go-modal branch July 30, 2026 16:16
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