react-resizable-panels 2.1.2 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/declarations/src/Panel.d.ts +3 -3
- package/dist/declarations/src/PanelResizeHandleRegistry.d.ts +1 -1
- package/dist/react-resizable-panels.browser.cjs.js +9 -1
- package/dist/react-resizable-panels.browser.development.cjs.js +9 -1
- package/dist/react-resizable-panels.browser.development.esm.js +9 -1
- package/dist/react-resizable-panels.browser.esm.js +9 -1
- package/dist/react-resizable-panels.cjs.js +9 -1
- package/dist/react-resizable-panels.development.cjs.js +9 -1
- package/dist/react-resizable-panels.development.esm.js +9 -1
- package/dist/react-resizable-panels.development.node.cjs.js +9 -1
- package/dist/react-resizable-panels.development.node.esm.js +9 -1
- package/dist/react-resizable-panels.esm.js +9 -1
- package/dist/react-resizable-panels.node.cjs.js +9 -1
- package/dist/react-resizable-panels.node.esm.js +9 -1
- package/package.json +1 -1
- package/src/Panel.ts +4 -5
- package/src/PanelGroup.ts +1 -0
- package/src/PanelResizeHandle.ts +5 -1
- package/src/PanelResizeHandleRegistry.ts +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.1.4
|
|
4
|
+
|
|
5
|
+
- Improve TypeScript HTML tag type generics (#407)
|
|
6
|
+
- Edge case check to make sure resize handle hasn't been unmounted while dragging (#410)
|
|
7
|
+
|
|
8
|
+
## 2.1.3
|
|
9
|
+
|
|
10
|
+
- Edge case bug fix for a resize handle unmounting while being dragged (#402)
|
|
11
|
+
|
|
3
12
|
## 2.1.2
|
|
13
|
+
|
|
4
14
|
- Suppress invalid layout warning for empty panel groups (#396)
|
|
5
15
|
|
|
6
16
|
## 2.1.1
|
|
@@ -30,7 +30,7 @@ export type ImperativePanelHandle = {
|
|
|
30
30
|
isExpanded: () => boolean;
|
|
31
31
|
resize: (size: number) => void;
|
|
32
32
|
};
|
|
33
|
-
export type PanelProps = Omit<HTMLAttributes<
|
|
33
|
+
export type PanelProps<T extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap> = Omit<HTMLAttributes<HTMLElementTagNameMap[T]>, "id" | "onResize"> & PropsWithChildren<{
|
|
34
34
|
className?: string;
|
|
35
35
|
collapsedSize?: number | undefined;
|
|
36
36
|
collapsible?: boolean | undefined;
|
|
@@ -43,7 +43,7 @@ export type PanelProps = Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id"
|
|
|
43
43
|
onResize?: PanelOnResize;
|
|
44
44
|
order?: number;
|
|
45
45
|
style?: object;
|
|
46
|
-
tagName?:
|
|
46
|
+
tagName?: T;
|
|
47
47
|
}>;
|
|
48
48
|
export declare function PanelWithForwardedRef({ children, className: classNameFromProps, collapsedSize, collapsible, defaultSize, forwardedRef, id: idFromProps, maxSize, minSize, onCollapse, onExpand, onResize, order, style: styleFromProps, tagName: Type, ...rest }: PanelProps & {
|
|
49
49
|
forwardedRef: ForwardedRef<ImperativePanelHandle>;
|
|
@@ -51,7 +51,7 @@ export declare function PanelWithForwardedRef({ children, className: classNameFr
|
|
|
51
51
|
export declare namespace PanelWithForwardedRef {
|
|
52
52
|
var displayName: string;
|
|
53
53
|
}
|
|
54
|
-
export declare const Panel: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<
|
|
54
|
+
export declare const Panel: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLObjectElement | HTMLElement | HTMLSlotElement | HTMLStyleElement | HTMLTitleElement | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLButtonElement | HTMLCanvasElement | HTMLTableCaptionElement | HTMLTableColElement | HTMLDataElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDialogElement | HTMLDivElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHeadingElement | HTMLHeadElement | HTMLHRElement | HTMLHtmlElement | HTMLIFrameElement | HTMLImageElement | HTMLInputElement | HTMLLabelElement | HTMLLegendElement | HTMLLIElement | HTMLLinkElement | HTMLMapElement | HTMLMenuElement | HTMLMetaElement | HTMLMeterElement | HTMLOListElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOutputElement | HTMLParagraphElement | HTMLPictureElement | HTMLPreElement | HTMLProgressElement | HTMLScriptElement | HTMLSelectElement | HTMLSourceElement | HTMLSpanElement | HTMLTableElement | HTMLTableSectionElement | HTMLTableCellElement | HTMLTemplateElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTableRowElement | HTMLTrackElement | HTMLUListElement | HTMLVideoElement>, "id" | "onResize"> & {
|
|
55
55
|
className?: string | undefined;
|
|
56
56
|
collapsedSize?: number | undefined;
|
|
57
57
|
collapsible?: boolean | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Direction, ResizeEvent } from "./types.js";
|
|
2
2
|
export type ResizeHandlerAction = "down" | "move" | "up";
|
|
3
|
-
export type SetResizeHandlerState = (action: ResizeHandlerAction, isActive: boolean, event: ResizeEvent) => void;
|
|
3
|
+
export type SetResizeHandlerState = (action: ResizeHandlerAction, isActive: boolean, event: ResizeEvent | null) => void;
|
|
4
4
|
export type PointerHitAreaMargins = {
|
|
5
5
|
coarse: number;
|
|
6
6
|
fine: number;
|
|
@@ -485,6 +485,10 @@ function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins
|
|
|
485
485
|
intersectingHandles.splice(index, 1);
|
|
486
486
|
}
|
|
487
487
|
updateCursor();
|
|
488
|
+
|
|
489
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
490
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
491
|
+
setResizeHandlerState("up", true, null);
|
|
488
492
|
}
|
|
489
493
|
};
|
|
490
494
|
}
|
|
@@ -596,7 +600,7 @@ function recalculateIntersectingHandles({
|
|
|
596
600
|
// Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
|
|
597
601
|
// so at this point we need to compare stacking order of a potentially intersecting drag handle,
|
|
598
602
|
// and the element that was actually clicked/touched
|
|
599
|
-
if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
603
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
600
604
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
601
605
|
// That is why we only check potentially intersecting handles,
|
|
602
606
|
// and why we skip if the event target is within the handle's DOM
|
|
@@ -2082,6 +2086,8 @@ function PanelGroupWithForwardedRef({
|
|
|
2082
2086
|
resizePanel(panelData, nextMaxSize);
|
|
2083
2087
|
}
|
|
2084
2088
|
}, [resizePanel]);
|
|
2089
|
+
|
|
2090
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2085
2091
|
const startDragging = useCallback((dragHandleId, event) => {
|
|
2086
2092
|
const {
|
|
2087
2093
|
direction
|
|
@@ -2312,6 +2318,7 @@ function PanelResizeHandle({
|
|
|
2312
2318
|
case "down":
|
|
2313
2319
|
{
|
|
2314
2320
|
setState("drag");
|
|
2321
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2315
2322
|
startDragging(resizeHandleId, event);
|
|
2316
2323
|
const {
|
|
2317
2324
|
onDragging
|
|
@@ -2329,6 +2336,7 @@ function PanelResizeHandle({
|
|
|
2329
2336
|
if (state !== "drag") {
|
|
2330
2337
|
setState("hover");
|
|
2331
2338
|
}
|
|
2339
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2332
2340
|
resizeHandler(event);
|
|
2333
2341
|
break;
|
|
2334
2342
|
}
|
|
@@ -491,6 +491,10 @@ function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins
|
|
|
491
491
|
intersectingHandles.splice(index, 1);
|
|
492
492
|
}
|
|
493
493
|
updateCursor();
|
|
494
|
+
|
|
495
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
496
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
497
|
+
setResizeHandlerState("up", true, null);
|
|
494
498
|
}
|
|
495
499
|
};
|
|
496
500
|
}
|
|
@@ -602,7 +606,7 @@ function recalculateIntersectingHandles({
|
|
|
602
606
|
// Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
|
|
603
607
|
// so at this point we need to compare stacking order of a potentially intersecting drag handle,
|
|
604
608
|
// and the element that was actually clicked/touched
|
|
605
|
-
if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
609
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
606
610
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
607
611
|
// That is why we only check potentially intersecting handles,
|
|
608
612
|
// and why we skip if the event target is within the handle's DOM
|
|
@@ -2188,6 +2192,8 @@ function PanelGroupWithForwardedRef({
|
|
|
2188
2192
|
resizePanel(panelData, nextMaxSize);
|
|
2189
2193
|
}
|
|
2190
2194
|
}, [resizePanel]);
|
|
2195
|
+
|
|
2196
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2191
2197
|
const startDragging = useCallback((dragHandleId, event) => {
|
|
2192
2198
|
const {
|
|
2193
2199
|
direction
|
|
@@ -2418,6 +2424,7 @@ function PanelResizeHandle({
|
|
|
2418
2424
|
case "down":
|
|
2419
2425
|
{
|
|
2420
2426
|
setState("drag");
|
|
2427
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2421
2428
|
startDragging(resizeHandleId, event);
|
|
2422
2429
|
const {
|
|
2423
2430
|
onDragging
|
|
@@ -2435,6 +2442,7 @@ function PanelResizeHandle({
|
|
|
2435
2442
|
if (state !== "drag") {
|
|
2436
2443
|
setState("hover");
|
|
2437
2444
|
}
|
|
2445
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2438
2446
|
resizeHandler(event);
|
|
2439
2447
|
break;
|
|
2440
2448
|
}
|
|
@@ -467,6 +467,10 @@ function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins
|
|
|
467
467
|
intersectingHandles.splice(index, 1);
|
|
468
468
|
}
|
|
469
469
|
updateCursor();
|
|
470
|
+
|
|
471
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
472
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
473
|
+
setResizeHandlerState("up", true, null);
|
|
470
474
|
}
|
|
471
475
|
};
|
|
472
476
|
}
|
|
@@ -578,7 +582,7 @@ function recalculateIntersectingHandles({
|
|
|
578
582
|
// Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
|
|
579
583
|
// so at this point we need to compare stacking order of a potentially intersecting drag handle,
|
|
580
584
|
// and the element that was actually clicked/touched
|
|
581
|
-
if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
585
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
582
586
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
583
587
|
// That is why we only check potentially intersecting handles,
|
|
584
588
|
// and why we skip if the event target is within the handle's DOM
|
|
@@ -2164,6 +2168,8 @@ function PanelGroupWithForwardedRef({
|
|
|
2164
2168
|
resizePanel(panelData, nextMaxSize);
|
|
2165
2169
|
}
|
|
2166
2170
|
}, [resizePanel]);
|
|
2171
|
+
|
|
2172
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2167
2173
|
const startDragging = useCallback((dragHandleId, event) => {
|
|
2168
2174
|
const {
|
|
2169
2175
|
direction
|
|
@@ -2394,6 +2400,7 @@ function PanelResizeHandle({
|
|
|
2394
2400
|
case "down":
|
|
2395
2401
|
{
|
|
2396
2402
|
setState("drag");
|
|
2403
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2397
2404
|
startDragging(resizeHandleId, event);
|
|
2398
2405
|
const {
|
|
2399
2406
|
onDragging
|
|
@@ -2411,6 +2418,7 @@ function PanelResizeHandle({
|
|
|
2411
2418
|
if (state !== "drag") {
|
|
2412
2419
|
setState("hover");
|
|
2413
2420
|
}
|
|
2421
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2414
2422
|
resizeHandler(event);
|
|
2415
2423
|
break;
|
|
2416
2424
|
}
|
|
@@ -461,6 +461,10 @@ function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins
|
|
|
461
461
|
intersectingHandles.splice(index, 1);
|
|
462
462
|
}
|
|
463
463
|
updateCursor();
|
|
464
|
+
|
|
465
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
466
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
467
|
+
setResizeHandlerState("up", true, null);
|
|
464
468
|
}
|
|
465
469
|
};
|
|
466
470
|
}
|
|
@@ -572,7 +576,7 @@ function recalculateIntersectingHandles({
|
|
|
572
576
|
// Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
|
|
573
577
|
// so at this point we need to compare stacking order of a potentially intersecting drag handle,
|
|
574
578
|
// and the element that was actually clicked/touched
|
|
575
|
-
if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
579
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
576
580
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
577
581
|
// That is why we only check potentially intersecting handles,
|
|
578
582
|
// and why we skip if the event target is within the handle's DOM
|
|
@@ -2058,6 +2062,8 @@ function PanelGroupWithForwardedRef({
|
|
|
2058
2062
|
resizePanel(panelData, nextMaxSize);
|
|
2059
2063
|
}
|
|
2060
2064
|
}, [resizePanel]);
|
|
2065
|
+
|
|
2066
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2061
2067
|
const startDragging = useCallback((dragHandleId, event) => {
|
|
2062
2068
|
const {
|
|
2063
2069
|
direction
|
|
@@ -2288,6 +2294,7 @@ function PanelResizeHandle({
|
|
|
2288
2294
|
case "down":
|
|
2289
2295
|
{
|
|
2290
2296
|
setState("drag");
|
|
2297
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2291
2298
|
startDragging(resizeHandleId, event);
|
|
2292
2299
|
const {
|
|
2293
2300
|
onDragging
|
|
@@ -2305,6 +2312,7 @@ function PanelResizeHandle({
|
|
|
2305
2312
|
if (state !== "drag") {
|
|
2306
2313
|
setState("hover");
|
|
2307
2314
|
}
|
|
2315
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2308
2316
|
resizeHandler(event);
|
|
2309
2317
|
break;
|
|
2310
2318
|
}
|
|
@@ -487,6 +487,10 @@ function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins
|
|
|
487
487
|
intersectingHandles.splice(index, 1);
|
|
488
488
|
}
|
|
489
489
|
updateCursor();
|
|
490
|
+
|
|
491
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
492
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
493
|
+
setResizeHandlerState("up", true, null);
|
|
490
494
|
}
|
|
491
495
|
};
|
|
492
496
|
}
|
|
@@ -598,7 +602,7 @@ function recalculateIntersectingHandles({
|
|
|
598
602
|
// Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
|
|
599
603
|
// so at this point we need to compare stacking order of a potentially intersecting drag handle,
|
|
600
604
|
// and the element that was actually clicked/touched
|
|
601
|
-
if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
605
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
602
606
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
603
607
|
// That is why we only check potentially intersecting handles,
|
|
604
608
|
// and why we skip if the event target is within the handle's DOM
|
|
@@ -2084,6 +2088,8 @@ function PanelGroupWithForwardedRef({
|
|
|
2084
2088
|
resizePanel(panelData, nextMaxSize);
|
|
2085
2089
|
}
|
|
2086
2090
|
}, [resizePanel]);
|
|
2091
|
+
|
|
2092
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2087
2093
|
const startDragging = useCallback((dragHandleId, event) => {
|
|
2088
2094
|
const {
|
|
2089
2095
|
direction
|
|
@@ -2314,6 +2320,7 @@ function PanelResizeHandle({
|
|
|
2314
2320
|
case "down":
|
|
2315
2321
|
{
|
|
2316
2322
|
setState("drag");
|
|
2323
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2317
2324
|
startDragging(resizeHandleId, event);
|
|
2318
2325
|
const {
|
|
2319
2326
|
onDragging
|
|
@@ -2331,6 +2338,7 @@ function PanelResizeHandle({
|
|
|
2331
2338
|
if (state !== "drag") {
|
|
2332
2339
|
setState("hover");
|
|
2333
2340
|
}
|
|
2341
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2334
2342
|
resizeHandler(event);
|
|
2335
2343
|
break;
|
|
2336
2344
|
}
|
|
@@ -498,6 +498,10 @@ function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins
|
|
|
498
498
|
intersectingHandles.splice(index, 1);
|
|
499
499
|
}
|
|
500
500
|
updateCursor();
|
|
501
|
+
|
|
502
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
503
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
504
|
+
setResizeHandlerState("up", true, null);
|
|
501
505
|
}
|
|
502
506
|
};
|
|
503
507
|
}
|
|
@@ -609,7 +613,7 @@ function recalculateIntersectingHandles({
|
|
|
609
613
|
// Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
|
|
610
614
|
// so at this point we need to compare stacking order of a potentially intersecting drag handle,
|
|
611
615
|
// and the element that was actually clicked/touched
|
|
612
|
-
if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
616
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
613
617
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
614
618
|
// That is why we only check potentially intersecting handles,
|
|
615
619
|
// and why we skip if the event target is within the handle's DOM
|
|
@@ -2195,6 +2199,8 @@ function PanelGroupWithForwardedRef({
|
|
|
2195
2199
|
resizePanel(panelData, nextMaxSize);
|
|
2196
2200
|
}
|
|
2197
2201
|
}, [resizePanel]);
|
|
2202
|
+
|
|
2203
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2198
2204
|
const startDragging = useCallback((dragHandleId, event) => {
|
|
2199
2205
|
const {
|
|
2200
2206
|
direction
|
|
@@ -2425,6 +2431,7 @@ function PanelResizeHandle({
|
|
|
2425
2431
|
case "down":
|
|
2426
2432
|
{
|
|
2427
2433
|
setState("drag");
|
|
2434
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2428
2435
|
startDragging(resizeHandleId, event);
|
|
2429
2436
|
const {
|
|
2430
2437
|
onDragging
|
|
@@ -2442,6 +2449,7 @@ function PanelResizeHandle({
|
|
|
2442
2449
|
if (state !== "drag") {
|
|
2443
2450
|
setState("hover");
|
|
2444
2451
|
}
|
|
2452
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2445
2453
|
resizeHandler(event);
|
|
2446
2454
|
break;
|
|
2447
2455
|
}
|
|
@@ -474,6 +474,10 @@ function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins
|
|
|
474
474
|
intersectingHandles.splice(index, 1);
|
|
475
475
|
}
|
|
476
476
|
updateCursor();
|
|
477
|
+
|
|
478
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
479
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
480
|
+
setResizeHandlerState("up", true, null);
|
|
477
481
|
}
|
|
478
482
|
};
|
|
479
483
|
}
|
|
@@ -585,7 +589,7 @@ function recalculateIntersectingHandles({
|
|
|
585
589
|
// Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
|
|
586
590
|
// so at this point we need to compare stacking order of a potentially intersecting drag handle,
|
|
587
591
|
// and the element that was actually clicked/touched
|
|
588
|
-
if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
592
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
589
593
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
590
594
|
// That is why we only check potentially intersecting handles,
|
|
591
595
|
// and why we skip if the event target is within the handle's DOM
|
|
@@ -2171,6 +2175,8 @@ function PanelGroupWithForwardedRef({
|
|
|
2171
2175
|
resizePanel(panelData, nextMaxSize);
|
|
2172
2176
|
}
|
|
2173
2177
|
}, [resizePanel]);
|
|
2178
|
+
|
|
2179
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2174
2180
|
const startDragging = useCallback((dragHandleId, event) => {
|
|
2175
2181
|
const {
|
|
2176
2182
|
direction
|
|
@@ -2401,6 +2407,7 @@ function PanelResizeHandle({
|
|
|
2401
2407
|
case "down":
|
|
2402
2408
|
{
|
|
2403
2409
|
setState("drag");
|
|
2410
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2404
2411
|
startDragging(resizeHandleId, event);
|
|
2405
2412
|
const {
|
|
2406
2413
|
onDragging
|
|
@@ -2418,6 +2425,7 @@ function PanelResizeHandle({
|
|
|
2418
2425
|
if (state !== "drag") {
|
|
2419
2426
|
setState("hover");
|
|
2420
2427
|
}
|
|
2428
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2421
2429
|
resizeHandler(event);
|
|
2422
2430
|
break;
|
|
2423
2431
|
}
|
|
@@ -460,6 +460,10 @@ function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins
|
|
|
460
460
|
intersectingHandles.splice(index, 1);
|
|
461
461
|
}
|
|
462
462
|
updateCursor();
|
|
463
|
+
|
|
464
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
465
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
466
|
+
setResizeHandlerState("up", true, null);
|
|
463
467
|
}
|
|
464
468
|
};
|
|
465
469
|
}
|
|
@@ -571,7 +575,7 @@ function recalculateIntersectingHandles({
|
|
|
571
575
|
// Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
|
|
572
576
|
// so at this point we need to compare stacking order of a potentially intersecting drag handle,
|
|
573
577
|
// and the element that was actually clicked/touched
|
|
574
|
-
if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
578
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
575
579
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
576
580
|
// That is why we only check potentially intersecting handles,
|
|
577
581
|
// and why we skip if the event target is within the handle's DOM
|
|
@@ -1963,6 +1967,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1963
1967
|
resizePanel(panelData, nextMaxSize);
|
|
1964
1968
|
}
|
|
1965
1969
|
}, [resizePanel]);
|
|
1970
|
+
|
|
1971
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
1966
1972
|
const startDragging = useCallback((dragHandleId, event) => {
|
|
1967
1973
|
const {
|
|
1968
1974
|
direction
|
|
@@ -2190,6 +2196,7 @@ function PanelResizeHandle({
|
|
|
2190
2196
|
case "down":
|
|
2191
2197
|
{
|
|
2192
2198
|
setState("drag");
|
|
2199
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2193
2200
|
startDragging(resizeHandleId, event);
|
|
2194
2201
|
const {
|
|
2195
2202
|
onDragging
|
|
@@ -2207,6 +2214,7 @@ function PanelResizeHandle({
|
|
|
2207
2214
|
if (state !== "drag") {
|
|
2208
2215
|
setState("hover");
|
|
2209
2216
|
}
|
|
2217
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2210
2218
|
resizeHandler(event);
|
|
2211
2219
|
break;
|
|
2212
2220
|
}
|
|
@@ -436,6 +436,10 @@ function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins
|
|
|
436
436
|
intersectingHandles.splice(index, 1);
|
|
437
437
|
}
|
|
438
438
|
updateCursor();
|
|
439
|
+
|
|
440
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
441
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
442
|
+
setResizeHandlerState("up", true, null);
|
|
439
443
|
}
|
|
440
444
|
};
|
|
441
445
|
}
|
|
@@ -547,7 +551,7 @@ function recalculateIntersectingHandles({
|
|
|
547
551
|
// Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
|
|
548
552
|
// so at this point we need to compare stacking order of a potentially intersecting drag handle,
|
|
549
553
|
// and the element that was actually clicked/touched
|
|
550
|
-
if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
554
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
551
555
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
552
556
|
// That is why we only check potentially intersecting handles,
|
|
553
557
|
// and why we skip if the event target is within the handle's DOM
|
|
@@ -1939,6 +1943,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1939
1943
|
resizePanel(panelData, nextMaxSize);
|
|
1940
1944
|
}
|
|
1941
1945
|
}, [resizePanel]);
|
|
1946
|
+
|
|
1947
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
1942
1948
|
const startDragging = useCallback((dragHandleId, event) => {
|
|
1943
1949
|
const {
|
|
1944
1950
|
direction
|
|
@@ -2166,6 +2172,7 @@ function PanelResizeHandle({
|
|
|
2166
2172
|
case "down":
|
|
2167
2173
|
{
|
|
2168
2174
|
setState("drag");
|
|
2175
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2169
2176
|
startDragging(resizeHandleId, event);
|
|
2170
2177
|
const {
|
|
2171
2178
|
onDragging
|
|
@@ -2183,6 +2190,7 @@ function PanelResizeHandle({
|
|
|
2183
2190
|
if (state !== "drag") {
|
|
2184
2191
|
setState("hover");
|
|
2185
2192
|
}
|
|
2193
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2186
2194
|
resizeHandler(event);
|
|
2187
2195
|
break;
|
|
2188
2196
|
}
|
|
@@ -463,6 +463,10 @@ function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins
|
|
|
463
463
|
intersectingHandles.splice(index, 1);
|
|
464
464
|
}
|
|
465
465
|
updateCursor();
|
|
466
|
+
|
|
467
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
468
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
469
|
+
setResizeHandlerState("up", true, null);
|
|
466
470
|
}
|
|
467
471
|
};
|
|
468
472
|
}
|
|
@@ -574,7 +578,7 @@ function recalculateIntersectingHandles({
|
|
|
574
578
|
// Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
|
|
575
579
|
// so at this point we need to compare stacking order of a potentially intersecting drag handle,
|
|
576
580
|
// and the element that was actually clicked/touched
|
|
577
|
-
if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
581
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
578
582
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
579
583
|
// That is why we only check potentially intersecting handles,
|
|
580
584
|
// and why we skip if the event target is within the handle's DOM
|
|
@@ -2060,6 +2064,8 @@ function PanelGroupWithForwardedRef({
|
|
|
2060
2064
|
resizePanel(panelData, nextMaxSize);
|
|
2061
2065
|
}
|
|
2062
2066
|
}, [resizePanel]);
|
|
2067
|
+
|
|
2068
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2063
2069
|
const startDragging = useCallback((dragHandleId, event) => {
|
|
2064
2070
|
const {
|
|
2065
2071
|
direction
|
|
@@ -2290,6 +2296,7 @@ function PanelResizeHandle({
|
|
|
2290
2296
|
case "down":
|
|
2291
2297
|
{
|
|
2292
2298
|
setState("drag");
|
|
2299
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2293
2300
|
startDragging(resizeHandleId, event);
|
|
2294
2301
|
const {
|
|
2295
2302
|
onDragging
|
|
@@ -2307,6 +2314,7 @@ function PanelResizeHandle({
|
|
|
2307
2314
|
if (state !== "drag") {
|
|
2308
2315
|
setState("hover");
|
|
2309
2316
|
}
|
|
2317
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2310
2318
|
resizeHandler(event);
|
|
2311
2319
|
break;
|
|
2312
2320
|
}
|
|
@@ -449,6 +449,10 @@ function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins
|
|
|
449
449
|
intersectingHandles.splice(index, 1);
|
|
450
450
|
}
|
|
451
451
|
updateCursor();
|
|
452
|
+
|
|
453
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
454
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
455
|
+
setResizeHandlerState("up", true, null);
|
|
452
456
|
}
|
|
453
457
|
};
|
|
454
458
|
}
|
|
@@ -560,7 +564,7 @@ function recalculateIntersectingHandles({
|
|
|
560
564
|
// Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
|
|
561
565
|
// so at this point we need to compare stacking order of a potentially intersecting drag handle,
|
|
562
566
|
// and the element that was actually clicked/touched
|
|
563
|
-
if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
567
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
564
568
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
565
569
|
// That is why we only check potentially intersecting handles,
|
|
566
570
|
// and why we skip if the event target is within the handle's DOM
|
|
@@ -1862,6 +1866,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1862
1866
|
resizePanel(panelData, nextMaxSize);
|
|
1863
1867
|
}
|
|
1864
1868
|
}, [resizePanel]);
|
|
1869
|
+
|
|
1870
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
1865
1871
|
const startDragging = useCallback((dragHandleId, event) => {
|
|
1866
1872
|
const {
|
|
1867
1873
|
direction
|
|
@@ -2089,6 +2095,7 @@ function PanelResizeHandle({
|
|
|
2089
2095
|
case "down":
|
|
2090
2096
|
{
|
|
2091
2097
|
setState("drag");
|
|
2098
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2092
2099
|
startDragging(resizeHandleId, event);
|
|
2093
2100
|
const {
|
|
2094
2101
|
onDragging
|
|
@@ -2106,6 +2113,7 @@ function PanelResizeHandle({
|
|
|
2106
2113
|
if (state !== "drag") {
|
|
2107
2114
|
setState("hover");
|
|
2108
2115
|
}
|
|
2116
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2109
2117
|
resizeHandler(event);
|
|
2110
2118
|
break;
|
|
2111
2119
|
}
|
|
@@ -425,6 +425,10 @@ function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins
|
|
|
425
425
|
intersectingHandles.splice(index, 1);
|
|
426
426
|
}
|
|
427
427
|
updateCursor();
|
|
428
|
+
|
|
429
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
430
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
431
|
+
setResizeHandlerState("up", true, null);
|
|
428
432
|
}
|
|
429
433
|
};
|
|
430
434
|
}
|
|
@@ -536,7 +540,7 @@ function recalculateIntersectingHandles({
|
|
|
536
540
|
// Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
|
|
537
541
|
// so at this point we need to compare stacking order of a potentially intersecting drag handle,
|
|
538
542
|
// and the element that was actually clicked/touched
|
|
539
|
-
if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
543
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
|
|
540
544
|
// Calculating stacking order has a cost, so we should avoid it if possible
|
|
541
545
|
// That is why we only check potentially intersecting handles,
|
|
542
546
|
// and why we skip if the event target is within the handle's DOM
|
|
@@ -1838,6 +1842,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1838
1842
|
resizePanel(panelData, nextMaxSize);
|
|
1839
1843
|
}
|
|
1840
1844
|
}, [resizePanel]);
|
|
1845
|
+
|
|
1846
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
1841
1847
|
const startDragging = useCallback((dragHandleId, event) => {
|
|
1842
1848
|
const {
|
|
1843
1849
|
direction
|
|
@@ -2065,6 +2071,7 @@ function PanelResizeHandle({
|
|
|
2065
2071
|
case "down":
|
|
2066
2072
|
{
|
|
2067
2073
|
setState("drag");
|
|
2074
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2068
2075
|
startDragging(resizeHandleId, event);
|
|
2069
2076
|
const {
|
|
2070
2077
|
onDragging
|
|
@@ -2082,6 +2089,7 @@ function PanelResizeHandle({
|
|
|
2082
2089
|
if (state !== "drag") {
|
|
2083
2090
|
setState("hover");
|
|
2084
2091
|
}
|
|
2092
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2085
2093
|
resizeHandler(event);
|
|
2086
2094
|
break;
|
|
2087
2095
|
}
|
package/package.json
CHANGED
package/src/Panel.ts
CHANGED
|
@@ -54,10 +54,9 @@ export type ImperativePanelHandle = {
|
|
|
54
54
|
resize: (size: number) => void;
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
export type PanelProps
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
> &
|
|
57
|
+
export type PanelProps<
|
|
58
|
+
T extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap,
|
|
59
|
+
> = Omit<HTMLAttributes<HTMLElementTagNameMap[T]>, "id" | "onResize"> &
|
|
61
60
|
PropsWithChildren<{
|
|
62
61
|
className?: string;
|
|
63
62
|
collapsedSize?: number | undefined;
|
|
@@ -71,7 +70,7 @@ export type PanelProps = Omit<
|
|
|
71
70
|
onResize?: PanelOnResize;
|
|
72
71
|
order?: number;
|
|
73
72
|
style?: object;
|
|
74
|
-
tagName?:
|
|
73
|
+
tagName?: T;
|
|
75
74
|
}>;
|
|
76
75
|
|
|
77
76
|
export function PanelWithForwardedRef({
|
package/src/PanelGroup.ts
CHANGED
|
@@ -816,6 +816,7 @@ function PanelGroupWithForwardedRef({
|
|
|
816
816
|
[resizePanel]
|
|
817
817
|
);
|
|
818
818
|
|
|
819
|
+
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
819
820
|
const startDragging = useCallback(
|
|
820
821
|
(dragHandleId: string, event: ResizeEvent) => {
|
|
821
822
|
const { direction } = committedValuesRef.current;
|
package/src/PanelResizeHandle.ts
CHANGED
|
@@ -129,13 +129,15 @@ export function PanelResizeHandle({
|
|
|
129
129
|
const setResizeHandlerState = (
|
|
130
130
|
action: ResizeHandlerAction,
|
|
131
131
|
isActive: boolean,
|
|
132
|
-
event: ResizeEvent
|
|
132
|
+
event: ResizeEvent | null
|
|
133
133
|
) => {
|
|
134
134
|
if (isActive) {
|
|
135
135
|
switch (action) {
|
|
136
136
|
case "down": {
|
|
137
137
|
setState("drag");
|
|
138
138
|
|
|
139
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
140
|
+
|
|
139
141
|
startDragging(resizeHandleId, event);
|
|
140
142
|
|
|
141
143
|
const { onDragging } = callbacksRef.current;
|
|
@@ -151,6 +153,8 @@ export function PanelResizeHandle({
|
|
|
151
153
|
setState("hover");
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
157
|
+
|
|
154
158
|
resizeHandler(event);
|
|
155
159
|
break;
|
|
156
160
|
}
|
|
@@ -9,7 +9,7 @@ export type ResizeHandlerAction = "down" | "move" | "up";
|
|
|
9
9
|
export type SetResizeHandlerState = (
|
|
10
10
|
action: ResizeHandlerAction,
|
|
11
11
|
isActive: boolean,
|
|
12
|
-
event: ResizeEvent
|
|
12
|
+
event: ResizeEvent | null
|
|
13
13
|
) => void;
|
|
14
14
|
|
|
15
15
|
export type PointerHitAreaMargins = {
|
|
@@ -83,6 +83,10 @@ export function registerResizeHandle(
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
updateCursor();
|
|
86
|
+
|
|
87
|
+
// Also instruct the handle to stop dragging; this prevents the parent group from being left in an inconsistent state
|
|
88
|
+
// See github.com/bvaughn/react-resizable-panels/issues/402
|
|
89
|
+
setResizeHandlerState("up", true, null);
|
|
86
90
|
}
|
|
87
91
|
};
|
|
88
92
|
}
|
|
@@ -193,6 +197,7 @@ function recalculateIntersectingHandles({
|
|
|
193
197
|
// and the element that was actually clicked/touched
|
|
194
198
|
if (
|
|
195
199
|
targetElement !== null &&
|
|
200
|
+
document.contains(targetElement) &&
|
|
196
201
|
dragHandleElement !== targetElement &&
|
|
197
202
|
!dragHandleElement.contains(targetElement) &&
|
|
198
203
|
!targetElement.contains(dragHandleElement) &&
|