-
Notifications
You must be signed in to change notification settings - Fork 601
♿️(frontend) limit share modal opening announcement for screen readers #2452
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?
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 |
|---|---|---|
|
|
@@ -40,6 +40,8 @@ import { | |
| import { QuickSearchGroupMember } from './DocShareMember'; | ||
| import { DocShareModalFooter } from './DocShareModalFooter'; | ||
|
|
||
| const DEBOUNCE_MS = 300; | ||
|
|
||
| const ShareModalStyle = createGlobalStyle` | ||
| .--docs--doc-share-modal [cmdk-item] { | ||
| cursor: auto; | ||
|
|
@@ -84,6 +86,7 @@ export const DocShareModal = ({ doc, onClose, isRootDoc = true }: Props) => { | |
|
|
||
| const [listHeight, setListHeight] = useState<string>('400px'); | ||
| const canShare = doc.abilities.accesses_manage && isRootDoc; | ||
| const [isContentAccessible, setIsContentAccessible] = useState(canShare); | ||
| const canViewAccesses = doc.abilities.accesses_view; | ||
| const showMemberSection = inputValue === '' && selectedUsers.length === 0; | ||
| const showFooter = selectedUsers.length === 0 && !inputValue; | ||
|
|
@@ -119,7 +122,7 @@ export const DocShareModal = ({ doc, onClose, isRootDoc = true }: Props) => { | |
|
|
||
| const onFilter = useDebouncedCallback((str: string) => { | ||
| setUserQuery(str); | ||
| }, 300); | ||
| }, DEBOUNCE_MS); | ||
|
|
||
| const onRemoveUser = (row: User) => { | ||
| setSelectedUsers((prevState) => { | ||
|
|
@@ -161,6 +164,20 @@ export const DocShareModal = ({ doc, onClose, isRootDoc = true }: Props) => { | |
| const showInheritedShareContent = | ||
| inheritedAccesses.length > 0 && showMemberSection && !isRootDoc; | ||
|
|
||
| // When the search input is hidden, keep the modal content out of the | ||
| // accessibility tree during the opening announcement, then restore it. | ||
| useEffect(() => { | ||
| if (canShare) { | ||
| return; | ||
| } | ||
|
|
||
| const id = window.setTimeout(() => { | ||
| setIsContentAccessible(true); | ||
| }, DEBOUNCE_MS); | ||
|
|
||
| return () => window.clearTimeout(id); | ||
| }, [canShare]); | ||
|
|
||
|
Comment on lines
+167
to
+180
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. Ensure Line 169 only handles the Suggested fix useEffect(() => {
- if (canShare) {
- return;
- }
+ setIsContentAccessible(canShare);
+ if (canShare) return;
const id = window.setTimeout(() => {
setIsContentAccessible(true);
}, DEBOUNCE_MS);
return () => window.clearTimeout(id);
}, [canShare]);Also applies to: 227-227 🤖 Prompt for AI Agents |
||
| // Invalidate relevant queries to ensure fresh data on modal open | ||
| useEffect(() => { | ||
| [ | ||
|
|
@@ -197,6 +214,7 @@ export const DocShareModal = ({ doc, onClose, isRootDoc = true }: Props) => { | |
| {t('Share the document')} | ||
| </Text> | ||
| <ButtonCloseModal | ||
| autoFocus={!canShare} | ||
| aria-label={t('Close the share modal')} | ||
| onClick={onClose} | ||
| /> | ||
|
|
@@ -206,6 +224,7 @@ export const DocShareModal = ({ doc, onClose, isRootDoc = true }: Props) => { | |
| > | ||
| <ShareModalStyle /> | ||
| <Box | ||
| aria-hidden={isContentAccessible ? undefined : true} | ||
| $height="auto" | ||
| $maxHeight={canViewAccesses ? modalContentHeight : 'none'} | ||
| $overflow="hidden" | ||
|
|
||
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.
🧹 Nitpick | 🔵 Trivial | ⚡ Quick win
Decouple search debounce timing from accessibility timing.
DEBOUNCE_MScurrently drives both query filtering (Line 125) and accessibility re-exposure delay (Line 176). This couples unrelated UX knobs and makes future tuning risky.Suggested refactor
Also applies to: 125-125, 176-176
🤖 Prompt for AI Agents