fix(editor): five locals in stepHistory and MoreTabs, sync tag in tests
This commit is contained in:
1 parent
08fab77d0e
commit
bb35e86dbb
5 files changed
+48
-35
No files matched your search
@@ -148,28 +148,32 @@ function MoreList({ more, active, onPick }: MoreListProps) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The panel of a tab picked in « Plus » takes the focus once that tab is the shown one: the
|
||||
* entry that held it is gone with the list, so the focus would fall to the page.
|
||||
* The choice of a tab in « Plus »: the menu closes, and the panel of the tab picked takes
|
||||
* the focus once that tab is the shown one (the entry that held it is gone with the list,
|
||||
* so the focus would fall to the page).
|
||||
*/
|
||||
function usePanelFocus(active: EditorTabId) {
|
||||
function usePanelPick(
|
||||
active: EditorTabId,
|
||||
onSelect: MoreTabsProps['onSelect'],
|
||||
close: () => void,
|
||||
) {
|
||||
const [wanted, setWanted] = useState<EditorTabId | null>(null)
|
||||
useEffect(() => {
|
||||
if (wanted === null || wanted !== active) return
|
||||
document.getElementById(panelDomId(active))?.focus()
|
||||
setWanted(null)
|
||||
}, [wanted, active])
|
||||
return setWanted
|
||||
return (tab: EditorTabId) => {
|
||||
if (onSelect(tab) !== false) setWanted(tab)
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
/** Below 640 px: « Plus » and its dropdown of the tabs that do not fit. */
|
||||
function MoreTabs({ more, active, onSelect }: MoreTabsProps) {
|
||||
const t = useT()
|
||||
const { open, close, toggle } = useMoreMenu(active)
|
||||
const wantPanel = usePanelFocus(active)
|
||||
const pick = (tab: EditorTabId) => {
|
||||
if (onSelect(tab) !== false) wantPanel(tab)
|
||||
close()
|
||||
}
|
||||
const pick = usePanelPick(active, onSelect, close)
|
||||
useMoreDismiss(open, close)
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in new issue
Block a user