Skip to content

Commit

Permalink
fix(range-selector): resets the selection after dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
Gggpound committed Nov 9, 2024
1 parent 2637287 commit caddba4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export const useSheetSelectionChange = (isNeed: boolean,
}, [sequenceNodes]);
oldFilterReferenceNodes.current = filterReferenceNodes;

const scalingOptionRef = useRef<{ result: string; offset: number }>();

useEffect(() => {
if (isNeed && refSelectionsRenderService) {
let isFirst = true;
Expand Down Expand Up @@ -130,6 +132,11 @@ export const useSheetSelectionChange = (isNeed: boolean,
const d1 = refSelectionsRenderService.selectionMoveEnd$.subscribe((selections) => {
handleSelectionsChange(selections, true);
isScalingRef.current = false;
if (scalingOptionRef.current) {
const { result, offset } = scalingOptionRef.current;
handleRangeChange(result, offset, true);
scalingOptionRef.current = undefined;
}
});

const d2 = refSelectionsRenderService.selectionMoving$.pipe(throttleTime(50)).subscribe((selections) => {
Expand Down Expand Up @@ -182,7 +189,8 @@ export const useSheetSelectionChange = (isNeed: boolean,
return node;
});
const result = sequenceNodeToText(newSequenceNodes);
handleRangeChange(result, offset || -1, false);
scalingOptionRef.current = { result, offset: offset || -1 };
handleRangeChange(result, -1, false);
};
let time = 0 as any;
const dispose = refSelectionsRenderService.selectionMoveEnd$.subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/

import type { IRangeSelectorProps } from '../';
import type { useFormulaToken } from './useFormulaToken';
import type { INode } from './useFormulaToken';
import { useEffect, useRef } from 'react';
import { sequenceNodeToText } from '../utils/sequenceNodeToText';
import { verifyRange } from '../utils/verifyRange';

export const useVerify = (isNeed: boolean, onVerify: IRangeSelectorProps['onVerify'], sequenceNodes: ReturnType<typeof useFormulaToken>['sequenceNodes']) => {
export const useVerify = (isNeed: boolean, onVerify: IRangeSelectorProps['onVerify'], sequenceNodes: INode[]) => {
const isInitRender = useRef(true);

// No validation is performed during the initialization phase.
Expand Down

0 comments on commit caddba4

Please sign in to comment.