fix(composer): keep first focus on the expert menu when opening options
48d7526 widened the options dialog first-focus selector to inputs, so the new story graph switch above the menus took initial focus. Keyboard users no longer landed on the expert / work mode menus like the model picker. Restore the button-only target; the switch stays reachable with Tab.
This commit is contained in:
@@ -333,7 +333,9 @@ export const Composer = memo(function Composer({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const frame = requestAnimationFrame(() => {
|
const frame = requestAnimationFrame(() => {
|
||||||
composerOptionsRef.current?.querySelector<HTMLElement>("input:not(:disabled), button:not(:disabled)")?.focus();
|
// Keyboard users land on the same first control as the model picker
|
||||||
|
// (expert / work mode menus); optional switches above stay Tab-reachable.
|
||||||
|
composerOptionsRef.current?.querySelector<HTMLButtonElement>("button:not(:disabled)")?.focus();
|
||||||
});
|
});
|
||||||
document.addEventListener("pointerdown", dismissOutside);
|
document.addEventListener("pointerdown", dismissOutside);
|
||||||
document.addEventListener("focusin", dismissOutside);
|
document.addEventListener("focusin", dismissOutside);
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ app.whenReady().then(async () => {
|
|||||||
const point = await js<{ x: number; y: number }>(`(() => { const r = document.querySelector('.composer__options-trigger').getBoundingClientRect(); return { x: Math.round(r.x+r.width/2), y: Math.round(r.y+r.height/2) }; })()`)
|
const point = await js<{ x: number; y: number }>(`(() => { const r = document.querySelector('.composer__options-trigger').getBoundingClientRect(); return { x: Math.round(r.x+r.width/2), y: Math.round(r.y+r.height/2) }; })()`)
|
||||||
win.webContents.sendInputEvent({ type: 'mouseDown', ...point, button: 'left', clickCount: 1 })
|
win.webContents.sendInputEvent({ type: 'mouseDown', ...point, button: 'left', clickCount: 1 })
|
||||||
win.webContents.sendInputEvent({ type: 'mouseUp', ...point, button: 'left', clickCount: 1 })
|
win.webContents.sendInputEvent({ type: 'mouseUp', ...point, button: 'left', clickCount: 1 })
|
||||||
await wait(`document.activeElement === document.querySelector('${toggle}')`)
|
// First focus stays on the first menu button, matching the model picker.
|
||||||
|
await wait('document.activeElement === document.querySelector(".composer__options button:not(:disabled)")')
|
||||||
}
|
}
|
||||||
const scenarios: object[] = []
|
const scenarios: object[] = []
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user