From 40f9302ec952904ebcc5ac9017e8ec32951dc838 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 3 Sep 2021 14:24:02 +0100 Subject: [PATCH 1/3] Space panel fix aria-expanded being set to false on nodes without children --- src/components/views/spaces/SpaceTreeLevel.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/views/spaces/SpaceTreeLevel.tsx b/src/components/views/spaces/SpaceTreeLevel.tsx index 399c137e97..3561fd19bf 100644 --- a/src/components/views/spaces/SpaceTreeLevel.tsx +++ b/src/components/views/spaces/SpaceTreeLevel.tsx @@ -270,8 +270,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 ? { /> : null; return ( -
  • +
  • Date: Fri, 3 Sep 2021 15:10:51 +0100 Subject: [PATCH 2/3] Fix keyboard dnd messing with roving tabindex --- src/components/views/spaces/SpacePanel.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/views/spaces/SpacePanel.tsx b/src/components/views/spaces/SpacePanel.tsx index d2e09c0d69..d3e41f8e58 100644 --- a/src/components/views/spaces/SpacePanel.tsx +++ b/src/components/views/spaces/SpacePanel.tsx @@ -223,6 +223,8 @@ const SpacePanel = () => { }, []); const onKeyDown = (ev: React.KeyboardEvent) => { + if (ev.defaultPrevented) return; + let handled = true; switch (ev.key) { From 898de13ca717cda3138628b184ecd41844693d62 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 6 Sep 2021 08:54:08 +0100 Subject: [PATCH 3/3] Consolidate roving tab index controls in the space panel buttons with dnd --- src/components/views/spaces/SpacePanel.tsx | 6 ++--- .../views/spaces/SpaceTreeLevel.tsx | 22 ++++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/views/spaces/SpacePanel.tsx b/src/components/views/spaces/SpacePanel.tsx index d3e41f8e58..d223f5b6a6 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) => ( , "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 { @@ -290,6 +298,9 @@ export class SpaceItem extends React.PureComponent { aria-label={collapsed ? _t("Expand") : _t("Collapse")} /> : null; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { tabIndex, ...dragHandleProps } = this.props.dragHandleProps || {}; + return (
  • { role="treeitem" >