refactor
This commit is contained in:
@@ -78,9 +78,6 @@ const persistWidth = (panel: PanelKey, value: number): void => {
|
||||
};
|
||||
|
||||
const applyPanelWidthToRoot = (panel: PanelKey, width: number, active: boolean): void => {
|
||||
if (!Number.isFinite(width)) {
|
||||
return;
|
||||
}
|
||||
const varName = panel === 'sidebar' ? '--sidebar-width' : '--detail-panel-width';
|
||||
const resolvedValue = panel === 'detail' && !active ? '0px' : `${width}px`;
|
||||
document.documentElement.style.setProperty(varName, resolvedValue);
|
||||
@@ -170,9 +167,7 @@ export const PanelManagerProvider: React.FC<PanelManagerProviderProps> = ({ chil
|
||||
const setPanelWidth = useCallback(
|
||||
(panel: PanelKey, width: number, { commit = true, log = true }: SetPanelWidthOptions = {}) => {
|
||||
const clamped = clampPanelWidth(panel, width);
|
||||
if (!Number.isFinite(clamped)) {
|
||||
return panelWidthsRef.current[panel];
|
||||
}
|
||||
|
||||
if (panel === 'sidebar') {
|
||||
setSidebarWidthState((prev) => (prev === clamped ? prev : clamped));
|
||||
} else {
|
||||
@@ -348,10 +343,7 @@ export const usePanelResizeBindings = (
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const rect = panelRef.current.getBoundingClientRect();
|
||||
const startWidth = Number.isFinite(rect?.width) ? rect.width : getPanelWidth(panel);
|
||||
if (!Number.isFinite(startWidth)) {
|
||||
return;
|
||||
}
|
||||
const startWidth = rect?.width ?? getPanelWidth(panel);
|
||||
const pointerId = event.pointerId ?? 'mouse';
|
||||
const startX = event.clientX;
|
||||
startPanelResize(panel);
|
||||
@@ -398,9 +390,7 @@ export const usePanelResizeBindings = (
|
||||
],
|
||||
);
|
||||
|
||||
const panelStyle = enabled && Number.isFinite(liveWidth)
|
||||
? { width: `${liveWidth}px` }
|
||||
: undefined;
|
||||
const panelStyle = enabled ? { width: `${liveWidth}px` } : undefined;
|
||||
|
||||
const handleProps = enabled
|
||||
? {
|
||||
|
||||
Reference in New Issue
Block a user