diff --git a/src/components/views/spaces/SpacePanel.tsx b/src/components/views/spaces/SpacePanel.tsx index d2e09c0d692..d223f5b6a62 100644 --- a/src/components/views/spaces/SpacePanel.tsx +++ b/src/components/views/spaces/SpacePanel.tsx @@ -195,12 +195,10 @@ const InnerSpacePanel = React.memo(({ children, isPanelCo { (provided, snapshot) => ( { }, []); const onKeyDown = (ev: React.KeyboardEvent) => { + if (ev.defaultPrevented) return; + let handled = true; switch (ev.key) { diff --git a/src/components/views/spaces/SpaceTreeLevel.tsx b/src/components/views/spaces/SpaceTreeLevel.tsx index 399c137e974..dda58ae9444 100644 --- a/src/components/views/spaces/SpaceTreeLevel.tsx +++ b/src/components/views/spaces/SpaceTreeLevel.tsx @@ -29,7 +29,6 @@ import RoomAvatar from "../avatars/RoomAvatar"; import SpaceStore from "../../../stores/SpaceStore"; import SpaceTreeLevelLayoutStore from "../../../stores/SpaceTreeLevelLayoutStore"; import NotificationBadge from "../rooms/NotificationBadge"; -import { RovingAccessibleTooltipButton } from "../../../accessibility/roving/RovingAccessibleTooltipButton"; import { _t } from "../../../languageHandler"; import { ContextMenuTooltipButton } from "../../../accessibility/context_menu/ContextMenuTooltipButton"; import { toRightOf, useContextMenu } from "../../structures/ContextMenu"; @@ -40,8 +39,11 @@ import { NotificationColor } from "../../../stores/notifications/NotificationCol import { getKeyBindingsManager, RoomListAction } from "../../../KeyBindingsManager"; import { NotificationState } from "../../../stores/notifications/NotificationState"; import SpaceContextMenu from "../context_menus/SpaceContextMenu"; +import AccessibleTooltipButton from "../elements/AccessibleTooltipButton"; +import { DraggableProvidedDragHandleProps } from "react-beautiful-dnd"; +import { useRovingTabIndex } from "../../../accessibility/RovingTabIndex"; -interface IButtonProps extends Omit, "title"> { +interface IButtonProps extends Omit, "title"> { space?: Room; className?: string; selected?: boolean; @@ -68,7 +70,9 @@ export const SpaceButton: React.FC = ({ ContextMenuComponent, ...props }) => { - const [menuDisplayed, handle, openMenu, closeMenu] = useContextMenu(); + const [menuDisplayed, ref, openMenu, closeMenu] = useContextMenu(); + const [onFocus, isActive, handle] = useRovingTabIndex(ref); + const tabIndex = isActive ? 0 : -1; let avatar =
; if (space) { @@ -88,6 +92,7 @@ export const SpaceButton: React.FC = ({ forceCount={false} notification={notificationState} aria-label={ariaLabel} + tabIndex={tabIndex} />
; } @@ -102,7 +107,7 @@ export const SpaceButton: React.FC = ({ } return ( - = ({ onContextMenu={openMenu} forceHide={!isNarrow || menuDisplayed} inputRef={handle} + tabIndex={tabIndex} + onFocus={onFocus} > { children }
@@ -130,7 +137,7 @@ export const SpaceButton: React.FC = ({ { contextMenu }
-
+ ); }; @@ -142,6 +149,7 @@ interface IItemProps extends InputHTMLAttributes { onExpand?: Function; parents?: Set; innerRef?: LegacyRef; + dragHandleProps?: DraggableProvidedDragHandleProps; } interface IItemState { @@ -270,8 +278,10 @@ export class SpaceItem extends React.PureComponent { ? StaticNotificationState.forSymbol("!", NotificationColor.Red) : SpaceStore.instance.getNotificationState(space.roomId); + const hasChildren = this.state.childSpaces?.length; + let childItems; - if (this.state.childSpaces?.length && !collapsed) { + if (hasChildren && !collapsed) { childItems = { />; } - const toggleCollapseButton = this.state.childSpaces?.length ? + const toggleCollapseButton = hasChildren ? { aria-label={collapsed ? _t("Expand") : _t("Collapse")} /> : null; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { tabIndex, ...dragHandleProps } = this.props.dragHandleProps || {}; + return ( -
  • +