Fix initial condition for shift/ctrl selection to work (#1908)
This commit is contained in:
parent
bcd8b7229f
commit
77c758714d
|
@ -92,6 +92,9 @@ export class DocumentsTabV2 extends TabsBase {
|
|||
// Use this value to initialize the very time the component is rendered
|
||||
const RESET_INDEX = -1;
|
||||
|
||||
// Auto-select first row. Define as constant to show where first row is selected
|
||||
export const INITIAL_SELECTED_ROW_INDEX = 0;
|
||||
|
||||
const filterButtonStyle: CSSProperties = {
|
||||
marginLeft: 8,
|
||||
};
|
||||
|
@ -506,8 +509,8 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
|
|||
currentClickedRowIndex > documentIds.length - 1
|
||||
) {
|
||||
// reset clicked row or the current clicked row is out of bounds
|
||||
currentClickedRowIndex = 0;
|
||||
setSelectedRows(new Set([0]));
|
||||
currentClickedRowIndex = INITIAL_SELECTED_ROW_INDEX;
|
||||
setSelectedRows(new Set([INITIAL_SELECTED_ROW_INDEX]));
|
||||
onDocumentClicked(currentClickedRowIndex, documentIds);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import {
|
|||
useTableSelection,
|
||||
} from "@fluentui/react-components";
|
||||
import { NormalizedEventKey } from "Common/Constants";
|
||||
import { INITIAL_SELECTED_ROW_INDEX } from "Explorer/Tabs/DocumentsTabV2/DocumentsTabV2";
|
||||
import { selectionHelper } from "Explorer/Tabs/DocumentsTabV2/SelectionHelper";
|
||||
import { isEnvironmentCtrlPressed, isEnvironmentShiftPressed } from "Utils/KeyboardUtils";
|
||||
import React, { useCallback, useMemo } from "react";
|
||||
|
@ -123,7 +124,7 @@ export const DocumentsTableComponent: React.FC<IDocumentsTableComponentProps> =
|
|||
[columnHeaders],
|
||||
);
|
||||
|
||||
const [selectionStartIndex, setSelectionStartIndex] = React.useState<number>(undefined);
|
||||
const [selectionStartIndex, setSelectionStartIndex] = React.useState<number>(INITIAL_SELECTED_ROW_INDEX);
|
||||
const onTableCellClicked = useCallback(
|
||||
(e: React.MouseEvent, index: number) => {
|
||||
if (isSelectionDisabled) {
|
||||
|
|
Loading…
Reference in New Issue