Repository navigation
fix(Comments): Mark as resolved and Reopen hand focus to the replacing control in the comment header #14155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(Comments): Mark as resolved and Reopen hand focus to the replacing control in the comment header #14155
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [chore] Internal: the focus hand-off Core runs when it replaces one of a control's elements ignores an element while it is inside an inert region, such as the copy OverflowList renders to measure its items, and Core's internal `@astryxdesign/core/internal/touch` entry re-exports it for Astryx's own packages, so Lab's Comments carries focus from Mark as resolved to Reopen and back while the replacing control shows in the comment's header. It is not part of the public API. Apps see no change. | ||
|
|
||
| @ernestt |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,13 @@ | |
| * @position Internal parts of a comment row in the Comments family | ||
| */ | ||
|
|
||
| import {useCallback, useRef, useState, type ReactNode} from 'react'; | ||
| import { | ||
| useCallback, | ||
| useRef, | ||
| useState, | ||
| type ReactNode, | ||
| type RefCallback, | ||
| } from 'react'; | ||
| import {flushSync} from 'react-dom'; | ||
| import * as stylex from '@stylexjs/stylex'; | ||
| import {Button} from '@astryxdesign/core/Button'; | ||
|
|
@@ -57,7 +63,12 @@ const styles = stylex.create({ | |
| export type CommentActionId = 'resolve' | 'reopen' | 'react' | 'reply' | 'link'; | ||
|
|
||
| /** Mark as resolved on an open thread, Reopen on a resolved one. */ | ||
| export type ResolveAction = {kind: 'resolve' | 'reopen'; onClick: () => void}; | ||
| export type ResolveAction = { | ||
| kind: 'resolve' | 'reopen'; | ||
| onClick: () => void; | ||
| /** Carries focus to the control that replaces a pressed one. */ | ||
| controlRef?: RefCallback<HTMLElement>; | ||
| }; | ||
|
|
||
| /** One of a comment's action buttons, as it shows. OverflowList renders a | ||
| * hidden copy of every item to measure it; only the copy in the visible list | ||
|
|
@@ -401,6 +412,7 @@ export function CommentActions({ | |
| {resolveAction?.kind === 'resolve' ? ( | ||
| <IconButton | ||
| key="resolve" | ||
| ref={resolveAction.controlRef} | ||
| label={resolveLabel} | ||
| tooltip={resolveLabel} | ||
| variant="ghost" | ||
|
|
@@ -413,6 +425,7 @@ export function CommentActions({ | |
| ) : resolveAction?.kind === 'reopen' ? ( | ||
| <Button | ||
| key="reopen" | ||
| ref={resolveAction.controlRef} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Miss: this ref hands focus to Reopen, but Reopen (75 px) is wider than the Mark as resolved icon (28 px). OverflowList has no minimum and remeasures when the key changes, so in a narrow header Reopen moves into the more menu one commit later and focus falls to the page body (reproduced locally in the Margin Comment story). The more-menu trigger already keeps focus when the action is picked from the menu, so it is a natural target for that case. |
||
| label={reopenLabel} | ||
| variant="ghost" | ||
| size="sm" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking (source comments): the header is now 17 lines, and this sentence runs 28 words over two topics. A short comment beside the helper keeps the header near 12 lines:
The helper matches any element in an inert region, not only a copy, so
isInInertRegionwould also fit.