mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 18:46:17 +00:00
eslint: enable react-hooks checks
Also fix all errors, which can lead to subtile bugs. Mostly fixings deps and refactoring to make typescript happy.
This commit is contained in:
committed by
David Lechner
parent
ee466ac904
commit
9d71bb4734
@@ -39,7 +39,7 @@ type ToolbarItemFocusAria = {
|
||||
*/
|
||||
export function useToolbarItemFocus(props: { id: string }): ToolbarItemFocusAria {
|
||||
const { id } = props;
|
||||
const state = useContext(ToolbarStateContext);
|
||||
const { lastFocusedItem, setLastFocusedItem } = useContext(ToolbarStateContext);
|
||||
const focusManager = useFocusManager();
|
||||
|
||||
const onKeyDown = useCallback<KeyboardEventHandler<HTMLElement>>(
|
||||
@@ -66,11 +66,12 @@ export function useToolbarItemFocus(props: { id: string }): ToolbarItemFocusAria
|
||||
|
||||
const onFocus = useCallback<FocusEventHandler<HTMLElement>>(
|
||||
(e) => {
|
||||
state.setLastFocusedItem(e.target.id);
|
||||
setLastFocusedItem(e.target.id);
|
||||
},
|
||||
[state.setLastFocusedItem],
|
||||
[setLastFocusedItem],
|
||||
);
|
||||
const excludeFromTabOrder = id !== state.lastFocusedItem;
|
||||
|
||||
const excludeFromTabOrder = id !== lastFocusedItem;
|
||||
|
||||
return { toolbarItemFocusProps: { onKeyDown, onFocus }, excludeFromTabOrder };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user