react-resizable-panels 2.0.7 → 2.0.8

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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.8
4
+
5
+ - `Panel`/`PanelGroup`/`PanelResizeHandle`` pass "id" prop through to DOM (#299)
6
+ - `Panel` attributes `data-panel-collapsible` and `data-panel-size` are no longer DEV-only (#297)
7
+
3
8
  ## 2.0.7
4
9
 
5
10
  - Group default layouts use `toPrecision` to avoid small layout shifts due to floating point precision differences between initial server rendering and client hydration (#295)
@@ -180,17 +180,17 @@ function PanelWithForwardedRef({
180
180
  ...rest,
181
181
  children,
182
182
  className: classNameFromProps,
183
+ id: idFromProps,
183
184
  style: {
184
185
  ...style,
185
186
  ...styleFromProps
186
187
  },
187
188
  // CSS selectors
188
189
  "data-panel": "",
189
- "data-panel-id": panelId,
190
+ "data-panel-collapsible": collapsible || undefined,
190
191
  "data-panel-group-id": groupId,
191
- // e2e test attributes
192
- "data-panel-collapsible": undefined,
193
- "data-panel-size": undefined
192
+ "data-panel-id": panelId,
193
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
194
194
  });
195
195
  }
196
196
  const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
@@ -1973,11 +1973,12 @@ function PanelGroupWithForwardedRef({
1973
1973
  ...rest,
1974
1974
  children,
1975
1975
  className: classNameFromProps,
1976
+ id: idFromProps,
1977
+ ref: panelGroupElementRef,
1976
1978
  style: {
1977
1979
  ...style,
1978
1980
  ...styleFromProps
1979
1981
  },
1980
- ref: panelGroupElementRef,
1981
1982
  // CSS selectors
1982
1983
  "data-panel-group": "",
1983
1984
  "data-panel-group-direction": direction,
@@ -2181,6 +2182,7 @@ function PanelResizeHandle({
2181
2182
  ...rest,
2182
2183
  children,
2183
2184
  className: classNameFromProps,
2185
+ id: idFromProps,
2184
2186
  onBlur: () => setIsFocused(false),
2185
2187
  onFocus: () => setIsFocused(true),
2186
2188
  ref: elementRef,
@@ -186,17 +186,17 @@ function PanelWithForwardedRef({
186
186
  ...rest,
187
187
  children,
188
188
  className: classNameFromProps,
189
+ id: idFromProps,
189
190
  style: {
190
191
  ...style,
191
192
  ...styleFromProps
192
193
  },
193
194
  // CSS selectors
194
195
  "data-panel": "",
195
- "data-panel-id": panelId,
196
+ "data-panel-collapsible": collapsible || undefined,
196
197
  "data-panel-group-id": groupId,
197
- // e2e test attributes
198
- "data-panel-collapsible": collapsible || undefined ,
199
- "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
198
+ "data-panel-id": panelId,
199
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
200
200
  });
201
201
  }
202
202
  const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
@@ -2079,11 +2079,12 @@ function PanelGroupWithForwardedRef({
2079
2079
  ...rest,
2080
2080
  children,
2081
2081
  className: classNameFromProps,
2082
+ id: idFromProps,
2083
+ ref: panelGroupElementRef,
2082
2084
  style: {
2083
2085
  ...style,
2084
2086
  ...styleFromProps
2085
2087
  },
2086
- ref: panelGroupElementRef,
2087
2088
  // CSS selectors
2088
2089
  "data-panel-group": "",
2089
2090
  "data-panel-group-direction": direction,
@@ -2287,6 +2288,7 @@ function PanelResizeHandle({
2287
2288
  ...rest,
2288
2289
  children,
2289
2290
  className: classNameFromProps,
2291
+ id: idFromProps,
2290
2292
  onBlur: () => setIsFocused(false),
2291
2293
  onFocus: () => setIsFocused(true),
2292
2294
  ref: elementRef,
@@ -162,17 +162,17 @@ function PanelWithForwardedRef({
162
162
  ...rest,
163
163
  children,
164
164
  className: classNameFromProps,
165
+ id: idFromProps,
165
166
  style: {
166
167
  ...style,
167
168
  ...styleFromProps
168
169
  },
169
170
  // CSS selectors
170
171
  "data-panel": "",
171
- "data-panel-id": panelId,
172
+ "data-panel-collapsible": collapsible || undefined,
172
173
  "data-panel-group-id": groupId,
173
- // e2e test attributes
174
- "data-panel-collapsible": collapsible || undefined ,
175
- "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
174
+ "data-panel-id": panelId,
175
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
176
176
  });
177
177
  }
178
178
  const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
@@ -2055,11 +2055,12 @@ function PanelGroupWithForwardedRef({
2055
2055
  ...rest,
2056
2056
  children,
2057
2057
  className: classNameFromProps,
2058
+ id: idFromProps,
2059
+ ref: panelGroupElementRef,
2058
2060
  style: {
2059
2061
  ...style,
2060
2062
  ...styleFromProps
2061
2063
  },
2062
- ref: panelGroupElementRef,
2063
2064
  // CSS selectors
2064
2065
  "data-panel-group": "",
2065
2066
  "data-panel-group-direction": direction,
@@ -2263,6 +2264,7 @@ function PanelResizeHandle({
2263
2264
  ...rest,
2264
2265
  children,
2265
2266
  className: classNameFromProps,
2267
+ id: idFromProps,
2266
2268
  onBlur: () => setIsFocused(false),
2267
2269
  onFocus: () => setIsFocused(true),
2268
2270
  ref: elementRef,
@@ -156,17 +156,17 @@ function PanelWithForwardedRef({
156
156
  ...rest,
157
157
  children,
158
158
  className: classNameFromProps,
159
+ id: idFromProps,
159
160
  style: {
160
161
  ...style,
161
162
  ...styleFromProps
162
163
  },
163
164
  // CSS selectors
164
165
  "data-panel": "",
165
- "data-panel-id": panelId,
166
+ "data-panel-collapsible": collapsible || undefined,
166
167
  "data-panel-group-id": groupId,
167
- // e2e test attributes
168
- "data-panel-collapsible": undefined,
169
- "data-panel-size": undefined
168
+ "data-panel-id": panelId,
169
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
170
170
  });
171
171
  }
172
172
  const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
@@ -1949,11 +1949,12 @@ function PanelGroupWithForwardedRef({
1949
1949
  ...rest,
1950
1950
  children,
1951
1951
  className: classNameFromProps,
1952
+ id: idFromProps,
1953
+ ref: panelGroupElementRef,
1952
1954
  style: {
1953
1955
  ...style,
1954
1956
  ...styleFromProps
1955
1957
  },
1956
- ref: panelGroupElementRef,
1957
1958
  // CSS selectors
1958
1959
  "data-panel-group": "",
1959
1960
  "data-panel-group-direction": direction,
@@ -2157,6 +2158,7 @@ function PanelResizeHandle({
2157
2158
  ...rest,
2158
2159
  children,
2159
2160
  className: classNameFromProps,
2161
+ id: idFromProps,
2160
2162
  onBlur: () => setIsFocused(false),
2161
2163
  onFocus: () => setIsFocused(true),
2162
2164
  ref: elementRef,
@@ -182,17 +182,17 @@ function PanelWithForwardedRef({
182
182
  ...rest,
183
183
  children,
184
184
  className: classNameFromProps,
185
+ id: idFromProps,
185
186
  style: {
186
187
  ...style,
187
188
  ...styleFromProps
188
189
  },
189
190
  // CSS selectors
190
191
  "data-panel": "",
191
- "data-panel-id": panelId,
192
+ "data-panel-collapsible": collapsible || undefined,
192
193
  "data-panel-group-id": groupId,
193
- // e2e test attributes
194
- "data-panel-collapsible": undefined,
195
- "data-panel-size": undefined
194
+ "data-panel-id": panelId,
195
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
196
196
  });
197
197
  }
198
198
  const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
@@ -1975,11 +1975,12 @@ function PanelGroupWithForwardedRef({
1975
1975
  ...rest,
1976
1976
  children,
1977
1977
  className: classNameFromProps,
1978
+ id: idFromProps,
1979
+ ref: panelGroupElementRef,
1978
1980
  style: {
1979
1981
  ...style,
1980
1982
  ...styleFromProps
1981
1983
  },
1982
- ref: panelGroupElementRef,
1983
1984
  // CSS selectors
1984
1985
  "data-panel-group": "",
1985
1986
  "data-panel-group-direction": direction,
@@ -2183,6 +2184,7 @@ function PanelResizeHandle({
2183
2184
  ...rest,
2184
2185
  children,
2185
2186
  className: classNameFromProps,
2187
+ id: idFromProps,
2186
2188
  onBlur: () => setIsFocused(false),
2187
2189
  onFocus: () => setIsFocused(true),
2188
2190
  ref: elementRef,
@@ -193,17 +193,17 @@ function PanelWithForwardedRef({
193
193
  ...rest,
194
194
  children,
195
195
  className: classNameFromProps,
196
+ id: idFromProps,
196
197
  style: {
197
198
  ...style,
198
199
  ...styleFromProps
199
200
  },
200
201
  // CSS selectors
201
202
  "data-panel": "",
202
- "data-panel-id": panelId,
203
+ "data-panel-collapsible": collapsible || undefined,
203
204
  "data-panel-group-id": groupId,
204
- // e2e test attributes
205
- "data-panel-collapsible": collapsible || undefined ,
206
- "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
205
+ "data-panel-id": panelId,
206
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
207
207
  });
208
208
  }
209
209
  const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
@@ -2086,11 +2086,12 @@ function PanelGroupWithForwardedRef({
2086
2086
  ...rest,
2087
2087
  children,
2088
2088
  className: classNameFromProps,
2089
+ id: idFromProps,
2090
+ ref: panelGroupElementRef,
2089
2091
  style: {
2090
2092
  ...style,
2091
2093
  ...styleFromProps
2092
2094
  },
2093
- ref: panelGroupElementRef,
2094
2095
  // CSS selectors
2095
2096
  "data-panel-group": "",
2096
2097
  "data-panel-group-direction": direction,
@@ -2294,6 +2295,7 @@ function PanelResizeHandle({
2294
2295
  ...rest,
2295
2296
  children,
2296
2297
  className: classNameFromProps,
2298
+ id: idFromProps,
2297
2299
  onBlur: () => setIsFocused(false),
2298
2300
  onFocus: () => setIsFocused(true),
2299
2301
  ref: elementRef,
@@ -169,17 +169,17 @@ function PanelWithForwardedRef({
169
169
  ...rest,
170
170
  children,
171
171
  className: classNameFromProps,
172
+ id: idFromProps,
172
173
  style: {
173
174
  ...style,
174
175
  ...styleFromProps
175
176
  },
176
177
  // CSS selectors
177
178
  "data-panel": "",
178
- "data-panel-id": panelId,
179
+ "data-panel-collapsible": collapsible || undefined,
179
180
  "data-panel-group-id": groupId,
180
- // e2e test attributes
181
- "data-panel-collapsible": collapsible || undefined ,
182
- "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
181
+ "data-panel-id": panelId,
182
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
183
183
  });
184
184
  }
185
185
  const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
@@ -2062,11 +2062,12 @@ function PanelGroupWithForwardedRef({
2062
2062
  ...rest,
2063
2063
  children,
2064
2064
  className: classNameFromProps,
2065
+ id: idFromProps,
2066
+ ref: panelGroupElementRef,
2065
2067
  style: {
2066
2068
  ...style,
2067
2069
  ...styleFromProps
2068
2070
  },
2069
- ref: panelGroupElementRef,
2070
2071
  // CSS selectors
2071
2072
  "data-panel-group": "",
2072
2073
  "data-panel-group-direction": direction,
@@ -2270,6 +2271,7 @@ function PanelResizeHandle({
2270
2271
  ...rest,
2271
2272
  children,
2272
2273
  className: classNameFromProps,
2274
+ id: idFromProps,
2273
2275
  onBlur: () => setIsFocused(false),
2274
2276
  onFocus: () => setIsFocused(true),
2275
2277
  ref: elementRef,
@@ -155,17 +155,17 @@ function PanelWithForwardedRef({
155
155
  ...rest,
156
156
  children,
157
157
  className: classNameFromProps,
158
+ id: idFromProps,
158
159
  style: {
159
160
  ...style,
160
161
  ...styleFromProps
161
162
  },
162
163
  // CSS selectors
163
164
  "data-panel": "",
164
- "data-panel-id": panelId,
165
+ "data-panel-collapsible": collapsible || undefined,
165
166
  "data-panel-group-id": groupId,
166
- // e2e test attributes
167
- "data-panel-collapsible": collapsible || undefined ,
168
- "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
167
+ "data-panel-id": panelId,
168
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
169
169
  });
170
170
  }
171
171
  const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
@@ -1854,11 +1854,12 @@ function PanelGroupWithForwardedRef({
1854
1854
  ...rest,
1855
1855
  children,
1856
1856
  className: classNameFromProps,
1857
+ id: idFromProps,
1858
+ ref: panelGroupElementRef,
1857
1859
  style: {
1858
1860
  ...style,
1859
1861
  ...styleFromProps
1860
1862
  },
1861
- ref: panelGroupElementRef,
1862
1863
  // CSS selectors
1863
1864
  "data-panel-group": "",
1864
1865
  "data-panel-group-direction": direction,
@@ -2059,6 +2060,7 @@ function PanelResizeHandle({
2059
2060
  ...rest,
2060
2061
  children,
2061
2062
  className: classNameFromProps,
2063
+ id: idFromProps,
2062
2064
  onBlur: () => setIsFocused(false),
2063
2065
  onFocus: () => setIsFocused(true),
2064
2066
  ref: elementRef,
@@ -131,17 +131,17 @@ function PanelWithForwardedRef({
131
131
  ...rest,
132
132
  children,
133
133
  className: classNameFromProps,
134
+ id: idFromProps,
134
135
  style: {
135
136
  ...style,
136
137
  ...styleFromProps
137
138
  },
138
139
  // CSS selectors
139
140
  "data-panel": "",
140
- "data-panel-id": panelId,
141
+ "data-panel-collapsible": collapsible || undefined,
141
142
  "data-panel-group-id": groupId,
142
- // e2e test attributes
143
- "data-panel-collapsible": collapsible || undefined ,
144
- "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
143
+ "data-panel-id": panelId,
144
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
145
145
  });
146
146
  }
147
147
  const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
@@ -1830,11 +1830,12 @@ function PanelGroupWithForwardedRef({
1830
1830
  ...rest,
1831
1831
  children,
1832
1832
  className: classNameFromProps,
1833
+ id: idFromProps,
1834
+ ref: panelGroupElementRef,
1833
1835
  style: {
1834
1836
  ...style,
1835
1837
  ...styleFromProps
1836
1838
  },
1837
- ref: panelGroupElementRef,
1838
1839
  // CSS selectors
1839
1840
  "data-panel-group": "",
1840
1841
  "data-panel-group-direction": direction,
@@ -2035,6 +2036,7 @@ function PanelResizeHandle({
2035
2036
  ...rest,
2036
2037
  children,
2037
2038
  className: classNameFromProps,
2039
+ id: idFromProps,
2038
2040
  onBlur: () => setIsFocused(false),
2039
2041
  onFocus: () => setIsFocused(true),
2040
2042
  ref: elementRef,
@@ -158,17 +158,17 @@ function PanelWithForwardedRef({
158
158
  ...rest,
159
159
  children,
160
160
  className: classNameFromProps,
161
+ id: idFromProps,
161
162
  style: {
162
163
  ...style,
163
164
  ...styleFromProps
164
165
  },
165
166
  // CSS selectors
166
167
  "data-panel": "",
167
- "data-panel-id": panelId,
168
+ "data-panel-collapsible": collapsible || undefined,
168
169
  "data-panel-group-id": groupId,
169
- // e2e test attributes
170
- "data-panel-collapsible": undefined,
171
- "data-panel-size": undefined
170
+ "data-panel-id": panelId,
171
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
172
172
  });
173
173
  }
174
174
  const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
@@ -1951,11 +1951,12 @@ function PanelGroupWithForwardedRef({
1951
1951
  ...rest,
1952
1952
  children,
1953
1953
  className: classNameFromProps,
1954
+ id: idFromProps,
1955
+ ref: panelGroupElementRef,
1954
1956
  style: {
1955
1957
  ...style,
1956
1958
  ...styleFromProps
1957
1959
  },
1958
- ref: panelGroupElementRef,
1959
1960
  // CSS selectors
1960
1961
  "data-panel-group": "",
1961
1962
  "data-panel-group-direction": direction,
@@ -2159,6 +2160,7 @@ function PanelResizeHandle({
2159
2160
  ...rest,
2160
2161
  children,
2161
2162
  className: classNameFromProps,
2163
+ id: idFromProps,
2162
2164
  onBlur: () => setIsFocused(false),
2163
2165
  onFocus: () => setIsFocused(true),
2164
2166
  ref: elementRef,
@@ -144,17 +144,17 @@ function PanelWithForwardedRef({
144
144
  ...rest,
145
145
  children,
146
146
  className: classNameFromProps,
147
+ id: idFromProps,
147
148
  style: {
148
149
  ...style,
149
150
  ...styleFromProps
150
151
  },
151
152
  // CSS selectors
152
153
  "data-panel": "",
153
- "data-panel-id": panelId,
154
+ "data-panel-collapsible": collapsible || undefined,
154
155
  "data-panel-group-id": groupId,
155
- // e2e test attributes
156
- "data-panel-collapsible": undefined,
157
- "data-panel-size": undefined
156
+ "data-panel-id": panelId,
157
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
158
158
  });
159
159
  }
160
160
  const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
@@ -1753,11 +1753,12 @@ function PanelGroupWithForwardedRef({
1753
1753
  ...rest,
1754
1754
  children,
1755
1755
  className: classNameFromProps,
1756
+ id: idFromProps,
1757
+ ref: panelGroupElementRef,
1756
1758
  style: {
1757
1759
  ...style,
1758
1760
  ...styleFromProps
1759
1761
  },
1760
- ref: panelGroupElementRef,
1761
1762
  // CSS selectors
1762
1763
  "data-panel-group": "",
1763
1764
  "data-panel-group-direction": direction,
@@ -1958,6 +1959,7 @@ function PanelResizeHandle({
1958
1959
  ...rest,
1959
1960
  children,
1960
1961
  className: classNameFromProps,
1962
+ id: idFromProps,
1961
1963
  onBlur: () => setIsFocused(false),
1962
1964
  onFocus: () => setIsFocused(true),
1963
1965
  ref: elementRef,
@@ -120,17 +120,17 @@ function PanelWithForwardedRef({
120
120
  ...rest,
121
121
  children,
122
122
  className: classNameFromProps,
123
+ id: idFromProps,
123
124
  style: {
124
125
  ...style,
125
126
  ...styleFromProps
126
127
  },
127
128
  // CSS selectors
128
129
  "data-panel": "",
129
- "data-panel-id": panelId,
130
+ "data-panel-collapsible": collapsible || undefined,
130
131
  "data-panel-group-id": groupId,
131
- // e2e test attributes
132
- "data-panel-collapsible": undefined,
133
- "data-panel-size": undefined
132
+ "data-panel-id": panelId,
133
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
134
134
  });
135
135
  }
136
136
  const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
@@ -1729,11 +1729,12 @@ function PanelGroupWithForwardedRef({
1729
1729
  ...rest,
1730
1730
  children,
1731
1731
  className: classNameFromProps,
1732
+ id: idFromProps,
1733
+ ref: panelGroupElementRef,
1732
1734
  style: {
1733
1735
  ...style,
1734
1736
  ...styleFromProps
1735
1737
  },
1736
- ref: panelGroupElementRef,
1737
1738
  // CSS selectors
1738
1739
  "data-panel-group": "",
1739
1740
  "data-panel-group-direction": direction,
@@ -1934,6 +1935,7 @@ function PanelResizeHandle({
1934
1935
  ...rest,
1935
1936
  children,
1936
1937
  className: classNameFromProps,
1938
+ id: idFromProps,
1937
1939
  onBlur: () => setIsFocused(false),
1938
1940
  onFocus: () => setIsFocused(true),
1939
1941
  ref: elementRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable-panels",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "React components for resizable panel groups/layouts",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
6
6
  "license": "MIT",
@@ -738,6 +738,38 @@ describe("PanelGroup", () => {
738
738
  });
739
739
  });
740
740
 
741
+ describe("a11y", () => {
742
+ it("should pass explicit id prop to DOM", () => {
743
+ act(() => {
744
+ root.render(
745
+ <PanelGroup direction="horizontal">
746
+ <Panel id="explicit-id" />
747
+ </PanelGroup>
748
+ );
749
+ });
750
+
751
+ const element = container.querySelector("[data-panel]");
752
+
753
+ expect(element).not.toBeNull();
754
+ expect(element?.getAttribute("id")).toBe("explicit-id");
755
+ });
756
+
757
+ it("should not pass auto-generated id prop to DOM", () => {
758
+ act(() => {
759
+ root.render(
760
+ <PanelGroup direction="horizontal">
761
+ <Panel />
762
+ </PanelGroup>
763
+ );
764
+ });
765
+
766
+ const element = container.querySelector("[data-panel]");
767
+
768
+ expect(element).not.toBeNull();
769
+ expect(element?.getAttribute("id")).toBeNull();
770
+ });
771
+ });
772
+
741
773
  describe("DEV warnings", () => {
742
774
  it("should warn about server rendered panels with no default size", () => {
743
775
  jest.resetModules();
package/src/Panel.ts CHANGED
@@ -236,6 +236,7 @@ export function PanelWithForwardedRef({
236
236
 
237
237
  children,
238
238
  className: classNameFromProps,
239
+ id: idFromProps,
239
240
  style: {
240
241
  ...style,
241
242
  ...styleFromProps,
@@ -243,16 +244,10 @@ export function PanelWithForwardedRef({
243
244
 
244
245
  // CSS selectors
245
246
  "data-panel": "",
246
- "data-panel-id": panelId,
247
+ "data-panel-collapsible": collapsible || undefined,
247
248
  "data-panel-group-id": groupId,
248
-
249
- // e2e test attributes
250
- "data-panel-collapsible": isDevelopment
251
- ? collapsible || undefined
252
- : undefined,
253
- "data-panel-size": isDevelopment
254
- ? parseFloat("" + style.flexGrow).toFixed(1)
255
- : undefined,
249
+ "data-panel-id": panelId,
250
+ "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1),
256
251
  });
257
252
  }
258
253
 
@@ -276,6 +276,42 @@ describe("PanelGroup", () => {
276
276
  });
277
277
  });
278
278
 
279
+ describe("a11y", () => {
280
+ it("should pass explicit id prop to DOM", () => {
281
+ act(() => {
282
+ root.render(
283
+ <PanelGroup direction="horizontal" id="explicit-id">
284
+ <Panel />
285
+ <PanelResizeHandle />
286
+ <Panel />
287
+ </PanelGroup>
288
+ );
289
+ });
290
+
291
+ const element = container.querySelector("[data-panel-group]");
292
+
293
+ expect(element).not.toBeNull();
294
+ expect(element?.getAttribute("id")).toBe("explicit-id");
295
+ });
296
+
297
+ it("should not pass auto-generated id prop to DOM", () => {
298
+ act(() => {
299
+ root.render(
300
+ <PanelGroup direction="horizontal">
301
+ <Panel />
302
+ <PanelResizeHandle />
303
+ <Panel />
304
+ </PanelGroup>
305
+ );
306
+ });
307
+
308
+ const element = container.querySelector("[data-panel-group]");
309
+
310
+ expect(element).not.toBeNull();
311
+ expect(element?.getAttribute("id")).toBeNull();
312
+ });
313
+ });
314
+
279
315
  describe("DEV warnings", () => {
280
316
  it("should warn about unstable layouts without id and order props", () => {
281
317
  act(() => {
package/src/PanelGroup.ts CHANGED
@@ -880,13 +880,16 @@ function PanelGroupWithForwardedRef({
880
880
  { value: context },
881
881
  createElement(Type, {
882
882
  ...rest,
883
+
883
884
  children,
884
885
  className: classNameFromProps,
886
+ id: idFromProps,
887
+ ref: panelGroupElementRef,
885
888
  style: {
886
889
  ...style,
887
890
  ...styleFromProps,
888
891
  },
889
- ref: panelGroupElementRef,
892
+
890
893
  // CSS selectors
891
894
  "data-panel-group": "",
892
895
  "data-panel-group-direction": direction,
@@ -269,4 +269,40 @@ describe("PanelResizeHandle", () => {
269
269
  verifyAttribute(rightElement, "data-resize-handle-active", null);
270
270
  });
271
271
  });
272
+
273
+ describe("a11y", () => {
274
+ it("should pass explicit id prop to DOM", () => {
275
+ act(() => {
276
+ root.render(
277
+ <PanelGroup direction="horizontal">
278
+ <Panel />
279
+ <PanelResizeHandle id="explicit-id" />
280
+ <Panel />
281
+ </PanelGroup>
282
+ );
283
+ });
284
+
285
+ const element = container.querySelector("[data-resize-handle]");
286
+
287
+ expect(element).not.toBeNull();
288
+ expect(element?.getAttribute("id")).toBe("explicit-id");
289
+ });
290
+
291
+ it("should not pass auto-generated id prop to DOM", () => {
292
+ act(() => {
293
+ root.render(
294
+ <PanelGroup direction="horizontal">
295
+ <Panel />
296
+ <PanelResizeHandle />
297
+ <Panel />
298
+ </PanelGroup>
299
+ );
300
+ });
301
+
302
+ const element = container.querySelector("[data-resize-handle]");
303
+
304
+ expect(element).not.toBeNull();
305
+ expect(element?.getAttribute("id")).toBeNull();
306
+ });
307
+ });
272
308
  });
@@ -203,6 +203,7 @@ export function PanelResizeHandle({
203
203
 
204
204
  children,
205
205
  className: classNameFromProps,
206
+ id: idFromProps,
206
207
  onBlur: () => setIsFocused(false),
207
208
  onFocus: () => setIsFocused(true),
208
209
  ref: elementRef,