Add Escape dismissal for creator profile image lightbox#5
Merged
chiscookeke11 merged 1 commit intoMay 28, 2026
Merged
Conversation
Reviewer's GuideImplements an accessible lightbox for creator profile images using the shared Dialog component, scoped Escape key handling, focus restoration to the avatar trigger, and corresponding tests, while keeping non-image avatar behavior unchanged and improving avatar test queries to use accessible roles. Sequence diagram for Escape dismissal and focus restoration in creator profile image lightboxsequenceDiagram
actor User
participant CreatorProfileHeader
participant Dialog
participant DialogContent
participant avatarTriggerRef
User->>CreatorProfileHeader: click avatar button
CreatorProfileHeader->>CreatorProfileHeader: setAvatarLightboxOpen(true)
CreatorProfileHeader->>Dialog: open=avatarLightboxOpen
Dialog->>DialogContent: render DialogContent
User->>DialogContent: press Escape
DialogContent->>CreatorProfileHeader: onEscapeKeyDown()
CreatorProfileHeader->>CreatorProfileHeader: setAvatarLightboxOpen(false)
CreatorProfileHeader->>Dialog: onOpenChange(false)
Dialog->>DialogContent: unmount DialogContent
Dialog->>CreatorProfileHeader: onCloseAutoFocus(event)
CreatorProfileHeader->>CreatorProfileHeader: event.preventDefault()
CreatorProfileHeader->>avatarTriggerRef: focus()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In the
DialogContentonEscapeKeyDownhandler, consider accepting the event and callingevent.preventDefault()to ensure Escape is fully scoped to this lightbox and does not bubble to any page-level Escape handlers. - Since
avataris now reused in both the lightbox and non-lightbox branches, double-check that its internal ARIA/role semantics still make sense when nested inside a button (i.e., avoid redundant or conflictingrole="img"/labelling between the avatar and the lightbox image).
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the `DialogContent` `onEscapeKeyDown` handler, consider accepting the event and calling `event.preventDefault()` to ensure Escape is fully scoped to this lightbox and does not bubble to any page-level Escape handlers.
- Since `avatar` is now reused in both the lightbox and non-lightbox branches, double-check that its internal ARIA/role semantics still make sense when nested inside a button (i.e., avoid redundant or conflicting `role="img"`/labelling between the avatar and the lightbox image).Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Escapekey and have focus returned to the element that opened it.Description
DialogwhenavatarUrlis present and importDialog,DialogTrigger,DialogContent,DialogTitle, andDialogDescriptionfromsrc/components/ui/dialog.avatarLightboxOpenstate andavatarTriggerRefto control the lightbox and restore focus to the trigger on close viaonCloseAutoFocusand close it on Escape viaonEscapeKeyDown.avatarUrlare unaffected.src/components/common/__tests__/CreatorProfileHeader.test.tsxfor Escape-to-close/focus-restore and updatesrc/components/common/__tests__/CreatorInitialsAvatar.test.tsxto use the accessiblerole='img'query.Testing
pnpm test(Vitest) and all tests passed, including the newCreatorProfileHeadertest and the updatedCreatorInitialsAvatartest.pnpm lintand the linter completed without errors.pnpm buildand the production build completed successfully.Codex Task
Summary by Sourcery
Add an accessible lightbox for creator profile images that supports Escape-based dismissal and focus restoration to the avatar trigger.
New Features:
Enhancements:
Tests: