Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(range-selector): range-selector can not blur #3967

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { deserializeRangeWithSheet, serializeRange } from '@univerjs/engine-form

import { ObjectScope, UnitAction, UnitObject, UnitRole } from '@univerjs/protocol';
import { RangeProtectionRuleModel, setEndForRange, SheetsSelectionsService, WorksheetProtectionRuleModel } from '@univerjs/sheets';
import { ComponentManager, IDialogService, ISidebarService, useObservable } from '@univerjs/ui';
import { ComponentManager, IDialogService, ISidebarService, useObservable, useSidebarClick } from '@univerjs/ui';
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { RANGE_SELECTOR_COMPONENT_KEY } from '../../../common/keys';
import { UNIVER_SHEET_PERMISSION_USER_DIALOG, UNIVER_SHEET_PERMISSION_USER_DIALOG_ID } from '../../../consts/permission';
Expand Down Expand Up @@ -329,15 +329,16 @@ export const SheetPermissionPanelDetail = ({ fromSheetBar }: { fromSheetBar: boo
sheetPermissionPanelModel.setRule(rule);
};

const handlePanelClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
const handlePanelClick = (e: MouseEvent) => {
const handleOutClick = rangeSelectorActionsRef.current?.handleOutClick;
handleOutClick && handleOutClick(e, isFocusRangeSelectorSet);
handleOutClick && handleOutClick(e, () => isFocusRangeSelectorSet(false));
};

useSidebarClick(handlePanelClick);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook is suspicious. What about other focusable elements not in the panel, especially considering we are an SDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This focused state is left entirely to the external business of the component (different cases have different defocusing moments)

const rangeStr = activeRule?.ranges?.map((i) => serializeRange(i)).join(',');

return (
<div className={styles.permissionPanelDetailWrapper} onClick={handlePanelClick}>
<div className={styles.permissionPanelDetailWrapper}>
{/* <FormLayout className={styles.sheetPermissionPanelTitle} label={localeService.t('permission.panel.name')}>
<Input
value={activeRule?.name ?? ''}
Expand Down
Loading