Fix roving tab index getting confused after dragging space order (#10901)
* Fix roving tab index getting confused after dragging space order * Fix roving tab index for drag reordering * delint * Add test * Make types happier * Remove snapshot
This commit is contained in:
parent
2da199c41d
commit
d9d53870e3
3 changed files with 150 additions and 33 deletions
|
@ -330,6 +330,7 @@ const InnerSpacePanel = React.memo<IInnerSpacePanelProps>(
|
|||
);
|
||||
|
||||
const SpacePanel: React.FC = () => {
|
||||
const [dragging, setDragging] = useState(false);
|
||||
const [isPanelCollapsed, setPanelCollapsed] = useState(true);
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
useLayoutEffect(() => {
|
||||
|
@ -344,14 +345,19 @@ const SpacePanel: React.FC = () => {
|
|||
});
|
||||
|
||||
return (
|
||||
<DragDropContext
|
||||
onDragEnd={(result) => {
|
||||
if (!result.destination) return; // dropped outside the list
|
||||
SpaceStore.instance.moveRootSpace(result.source.index, result.destination.index);
|
||||
}}
|
||||
>
|
||||
<RovingTabIndexProvider handleHomeEnd handleUpDown>
|
||||
{({ onKeyDownHandler }) => (
|
||||
<RovingTabIndexProvider handleHomeEnd handleUpDown={!dragging}>
|
||||
{({ onKeyDownHandler, onDragEndHandler }) => (
|
||||
<DragDropContext
|
||||
onDragStart={() => {
|
||||
setDragging(true);
|
||||
}}
|
||||
onDragEnd={(result) => {
|
||||
setDragging(false);
|
||||
if (!result.destination) return; // dropped outside the list
|
||||
SpaceStore.instance.moveRootSpace(result.source.index, result.destination.index);
|
||||
onDragEndHandler();
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className={classNames("mx_SpacePanel", { collapsed: isPanelCollapsed })}
|
||||
onKeyDown={onKeyDownHandler}
|
||||
|
@ -395,9 +401,9 @@ const SpacePanel: React.FC = () => {
|
|||
|
||||
<QuickSettingsButton isPanelCollapsed={isPanelCollapsed} />
|
||||
</div>
|
||||
)}
|
||||
</RovingTabIndexProvider>
|
||||
</DragDropContext>
|
||||
</DragDropContext>
|
||||
)}
|
||||
</RovingTabIndexProvider>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue