mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 18:46:17 +00:00
add assert to work around react-aria typing changes
This commit is contained in:
committed by
David Lechner
parent
432bcbf7e5
commit
2d968381c4
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2022 The Pybricks Authors
|
||||
// Copyright (c) 2022-2023 The Pybricks Authors
|
||||
|
||||
import { filterDOMProps } from '@react-aria/utils';
|
||||
import {
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
useContext,
|
||||
} from 'react';
|
||||
import { FocusScope, mergeProps, useFocusManager } from 'react-aria';
|
||||
import { assert } from '../../utils';
|
||||
import { ToolbarStateContext } from './state';
|
||||
import type { AriaToolbarProps } from './types';
|
||||
|
||||
@@ -42,6 +43,11 @@ export function useToolbarItemFocus(props: { id: string }): ToolbarItemFocusAria
|
||||
const { lastFocusedItem, setLastFocusedItem } = useContext(ToolbarStateContext);
|
||||
const focusManager = useFocusManager();
|
||||
|
||||
assert(
|
||||
focusManager !== undefined,
|
||||
'useToolbarItemFocus must be inside of a FocusScope',
|
||||
);
|
||||
|
||||
const onKeyDown = useCallback<KeyboardEventHandler<HTMLElement>>(
|
||||
(e) => {
|
||||
switch (e.key) {
|
||||
|
||||
Reference in New Issue
Block a user