Skip to content

Commit 661ddff

Browse files
committed
Replace Panel aria-disabled attribute with data-disabled
1 parent ebf443d commit 661ddff

4 files changed

Lines changed: 4 additions & 91 deletions

File tree

lib/components/panel/Panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export function Panel({
168168
return (
169169
<div
170170
{...rest}
171-
aria-disabled={disabled || undefined}
171+
data-disabled={disabled || undefined}
172172
data-panel
173173
data-testid={id}
174174
id={id}

lib/global/dom/calculateHitRegions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function calculateHitRegions(group: RegisteredGroup) {
5252
if (childElement.hasAttribute("data-panel")) {
5353
currentPanelIndex++;
5454

55-
if (childElement.ariaDisabled === null) {
55+
if (!childElement.hasAttribute("data-disabled")) {
5656
numEnabledPanels++;
5757

5858
if (firstEnabledPanelIndex === -1) {

lib/global/test/mockGroup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function mockGroup(
9898
const element = document.createElement("div");
9999
element.setAttribute("data-panel", panelId);
100100
if (constraints?.disabled) {
101-
element.setAttribute("aria-disabled", "");
101+
element.setAttribute("data-disabled", "");
102102
}
103103

104104
setElementBounds(element, relativeBoundsToBounds(relativeBounds));

src/routes/DisabledPanelsRoute.tsx

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,10 @@
1-
import { Box, Callout, Code, Header } from "react-lib-tools";
2-
import { html as DisabledPanelHTML } from "../../public/generated/examples/DisabledPanel.json";
3-
import { html as DisabledPanelAndSeparatorHTML } from "../../public/generated/examples/DisabledPanelAndSeparator.json";
4-
import { html as DisabledPanelsHTML } from "../../public/generated/examples/DisabledPanels.json";
5-
import { html as DisabledSeparatorHTML } from "../../public/generated/examples/DisabledSeparator.json";
6-
import { Link } from "../components/Link";
1+
import { Box } from "react-lib-tools";
72
import { Group } from "../components/styled-panels/Group";
83
import { Panel } from "../components/styled-panels/Panel";
9-
import { Separator } from "../components/styled-panels/Separator";
104

115
export default function DisabledPanelsRoute() {
126
return (
137
<Box direction="column" gap={4}>
14-
<Header section="Examples" title="Disabling interactions" />
15-
<div>
16-
<code>Panel</code> and <code>Separator</code> components can be disabled
17-
to disable or limit resize behavior. Below are a few examples of how
18-
this can be used to implement different types of UIs.
19-
</div>
20-
<div>
21-
In groups with only two panels, disabling a separator is sufficient to
22-
completely prevent resizing.
23-
</div>
24-
<Code html={DisabledSeparatorHTML} />
25-
<Group>
26-
<Panel minSize={50}>left</Panel>
27-
<Separator disabled />
28-
<Panel minSize={50}>right</Panel>
29-
</Group>
30-
<div>
31-
The same applies to disabling one or both panels when there is no
32-
explicit separator element.
33-
</div>
34-
<Callout intent="primary">
35-
Note this is functionally the same as disabling the entire{" "}
36-
<code>Group</code> component.
37-
</Callout>
38-
<Code html={DisabledPanelsHTML} />
398
<Group>
409
<Panel disabled minSize={50}>
4110
left
@@ -44,62 +13,6 @@ export default function DisabledPanelsRoute() {
4413
right
4514
</Panel>
4615
</Group>
47-
<div>
48-
In groups with three or more panels, disabling a separator does not
49-
completely prevent a panel from being resized. In the example below,
50-
resizing the center panel can indirectly cause the left panel to be
51-
resized as well.
52-
</div>
53-
<Group>
54-
<Panel minSize={50}>left</Panel>
55-
<Separator disabled />
56-
<Panel minSize={50}>center</Panel>
57-
<Separator />
58-
<Panel minSize={50}>right</Panel>
59-
</Group>
60-
<div>
61-
Disabling a panel prevents it from being resized, though its separator
62-
can still be used to resize other panels.
63-
</div>
64-
<Code html={DisabledPanelHTML} />
65-
<Group>
66-
<Panel minSize={50}>left</Panel>
67-
<Separator />
68-
<Panel disabled minSize={50}>
69-
center (disabled)
70-
</Panel>
71-
<Separator />
72-
<Panel minSize={50}>right</Panel>
73-
</Group>
74-
<div>
75-
When there is no separator, a disabled panel's edges can also be used to
76-
resize other panels.
77-
</div>
78-
<Group>
79-
<Panel minSize={50}>left</Panel>
80-
<Panel disabled minSize={50}>
81-
center (disabled)
82-
</Panel>
83-
<Panel minSize={50}>right</Panel>
84-
</Group>
85-
<div>
86-
You can also disable both a panel and its separator to completely
87-
prevent them from being resized or interacted with in any way.
88-
</div>
89-
<Code html={DisabledPanelAndSeparatorHTML} />
90-
<Group>
91-
<Panel disabled minSize={50}>
92-
left (disabled)
93-
</Panel>
94-
<Separator disabled />
95-
<Panel minSize={50}>center</Panel>
96-
<Separator />
97-
<Panel minSize={50}>right</Panel>
98-
</Group>
99-
<Callout intent="primary">
100-
Note that a disabled <code>Panel</code> can still be resized using the{" "}
101-
<Link to="/imperative-api/panel">imperative API</Link>.
102-
</Callout>
10316
</Box>
10417
);
10518
}

0 commit comments

Comments
 (0)