Skip to content

Commit a803194

Browse files
committed
Release 4.11.0
1 parent 640b88d commit a803194

11 files changed

Lines changed: 61 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 4.11.0
4+
5+
- [712](https://github.com/bvaughn/react-resizable-panels/issues/712): `Separator` supports `:focus-visible` pseudo-class
6+
- [711](https://github.com/bvaughn/react-resizable-panels/issues/711): Improve legacy browser support wrt global stylesheets
7+
38
## 4.10.0
49

510
- [705](https://github.com/bvaughn/react-resizable-panels/pull/705): Add `data-separator="focus"` state for `Separator` elements for more consistent custom CSS styles.

lib/global/cursor/updateCursorStyle.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ export function updateCursorStyle(ownerDocument: Document) {
2626

2727
// adoptedStyleSheets is undefined in jsdom
2828
if (ownerDocument.adoptedStyleSheets) {
29-
ownerDocument.adoptedStyleSheets.push(styleSheet);
29+
if (Object.isExtensible(ownerDocument.adoptedStyleSheets)) {
30+
ownerDocument.adoptedStyleSheets.push(styleSheet);
31+
} else {
32+
ownerDocument.adoptedStyleSheets = [
33+
...ownerDocument.adoptedStyleSheets,
34+
styleSheet
35+
];
36+
}
3037
}
3138
}
3239

lib/global/event-handlers/onDocumentPointerDown.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export function onDocumentPointerDown(event: PointerEvent) {
2424
didChangeFocus = true;
2525

2626
current.separator.element.focus({
27+
// @ts-expect-error https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#browser_compatibility
28+
focusVisible: false,
2729
preventScroll: true
2830
});
2931

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-resizable-panels",
3-
"version": "4.10.0",
3+
"version": "4.11.0",
44
"type": "module",
55
"author": "Brian Vaughn <brian.david.vaughn@gmail.com> (https://github.com/bvaughn/)",
66
"contributors": [
@@ -97,7 +97,7 @@
9797
"react-docgen-typescript": "^2.4.0",
9898
"react-dom": "^19.2.3",
9999
"react-error-boundary": "^6.0.0",
100-
"react-lib-tools": "0.0.52",
100+
"react-lib-tools": "0.0.53",
101101
"react-router-dom": "^7.6.3",
102102
"rimraf": "^6.1.2",
103103
"rollup-plugin-terser": "^7.0.2",

pnpm-lock.yaml

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"html": "<div><span class=\"tok-punctuation\">&#60;</span><span class=\"tok-typeName\">Separator</span><span class=\"\"></span></div>\n<div><span class=\"\"> </span><span class=\"tok-propertyName\">className</span><span class=\"tok-operator\">=</span><span class=\"tok-string\">\"</span></div>\n<div><span class=\"tok-string\"> bg-slate-600</span></div>\n<div><span class=\"tok-string\"> [&#38;[data-separator='hover']]:bg-slate-500</span></div>\n<div><span class=\"tok-string\"> [&#38;[data-separator='active']]:bg-slate-400</span></div>\n<div><span class=\"tok-string\"> focus-visible:bg-sky-400!</span></div>\n<div><span class=\"tok-string\"> \"</span><span class=\"\"></span></div>\n<div><span class=\"\"></span><span class=\"tok-punctuation\">/&#62;</span></div>"
3+
}

public/generated/site-map.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{
1919
"path": "/examples/min-max-sizes",
2020
"section": "Examples",
21-
"text": " Panels can be configured with minimum/maximum allowed sizes. Size can be specified using the following CSS units: Pixels Percentages Font sizes (em, rem) Viewport sizes (vh, vw) For example, the left panel below only allows itself to be resized between 10v0-200 pixels. <Group>\n <Panel minSize={100} maxSize={200}>left</Panel>\n <Separator />\n <Panel>right</Panel>\n</Group> As another example, this panel group will not allow any individual panel to be smaller than 10% of the group's width. <Group>\n <Panel minSize=\"10%\">left</Panel>\n <Separator />\n <Panel minSize=\"10%\">middle</Panel>\n <Separator />\n <Panel minSize=\"10%\">right</Panel>\n</Group> When specifying sizes, remember: Numbers are evaluated as pixels. Strings are evaluated as percentages (0..100%) unless otherwise specified. You can always include the unit, even for pixels (e.g. minSize=\"100px\") or percentages (e.g. minSize=\"10%\") ",
21+
"text": " Panels can be configured with minimum/maximum allowed sizes. Size can be specified using the following CSS units: Pixels Percentages Font sizes (em, rem) Viewport sizes (vh, vw) For example, the left panel below only allows itself to be resized between 100-200 pixels. <Group>\n <Panel minSize={100} maxSize={200}>left</Panel>\n <Separator />\n <Panel>right</Panel>\n</Group> As another example, this panel group will not allow any individual panel to be smaller than 10% of the group's width. <Group>\n <Panel minSize=\"10%\">left</Panel>\n <Separator />\n <Panel minSize=\"10%\">middle</Panel>\n <Separator />\n <Panel minSize=\"10%\">right</Panel>\n</Group> When specifying sizes, remember: Numbers are evaluated as pixels. Strings are evaluated as percentages (0..100%) unless otherwise specified. You can always include the unit, even for pixels (e.g. minSize=\"100px\") or percentages (e.g. minSize=\"10%\") ",
2222
"title": "Min/max sizes"
2323
},
2424
{
@@ -90,7 +90,7 @@
9090
{
9191
"path": "/examples/custom-css-styles",
9292
"section": "Examples",
93-
"text": " className and style props can be used to customize styles, but there are a few limitations to remember: Certain style properties cannot be overridden; (refer to component documentation for a list of specific styles) Panel styles are applied to a nested HTMLDivElement to prevent interfering with the Flex layout When styling a Separator, use the data-separator attribute rather than :hover or :active pseudo-classes. This attribute is updated when the pointer is near enough to a separator element to be interactive, even if it is not directly on top of the element. <div data-separator=\"disabled\" />\n<div data-separator=\"inactive\" />\n<div data-separator=\"hover\" />\n<div data-separator=\"active\" />\n<div data-separator=\"focus\" /> An example using Tailwind CSS might look something like this. <Separator\n className=\"\n bg-slate-600\n [&[data-separator='hover']]:bg-slate-500\n [&[data-separator='active']]:bg-slate-400\n [&[data-separator='focus']]:bg-sky-400\n \"\n/> ",
93+
"text": " className and style props can be used to customize styles, but there are a few limitations to remember: Certain style properties cannot be overridden; (refer to component documentation for a list of specific styles) Panel styles are applied to a nested HTMLDivElement to prevent interfering with the Flex layout When styling a Separator, use the data-separator attribute rather than :hover or :active pseudo-classes. This attribute is updated when the pointer is near enough to a separator element to be interactive, even if it is not directly on top of the element. <div data-separator=\"disabled\" />\n<div data-separator=\"inactive\" />\n<div data-separator=\"hover\" />\n<div data-separator=\"active\" />\n<div data-separator=\"focus\" /> An example using Tailwind CSS might look something like this. <Separator\n className=\"\n bg-slate-600\n [&[data-separator='hover']]:bg-slate-500\n [&[data-separator='active']]:bg-slate-400\n [&[data-separator='focus']]:bg-sky-400\n \"\n/> If you want to differentiate between keyboard-initiated focus and pointer-initiated focus, you can use the :focus and :focus-visible CSS pseudo-class instead. <Separator\n className=\"\n bg-slate-600\n [&[data-separator='hover']]:bg-slate-500\n [&[data-separator='active']]:bg-slate-400\n focus-visible:bg-sky-400!\n \"\n/> ",
9494
"title": "Custom CSS styles"
9595
},
9696
{

scripts/compile-search-index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { compileSearchIndex } from "../../react-lib-tools/scripts/compile-search-index.ts";
1+
import { compileSearchIndex } from "react-lib-tools/scripts/compile-search-index.ts";
22

33
await compileSearchIndex({
44
chromeExecutablePath: process.env.CHROME_PATH,

src/components/styled-panels/Separator.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import GrabDotsIcon from "../../../public/svgs/grab-dots.svg?react";
1010
export function Separator({
1111
className = "",
1212
orientation = "horizontal",
13+
useFocusPseudoClasses,
1314
...rest
1415
}: PropsWithChildren<
1516
SeparatorProps & {
1617
orientation?: Orientation;
18+
useFocusPseudoClasses?: boolean;
1719
}
1820
>) {
1921
return (
@@ -22,7 +24,9 @@ export function Separator({
2224
"rounded rounded-xs flex items-center justify-center",
2325
"bg-slate-600 [&[data-separator='disabled']]:opacity-50 [&[data-separator='hover']]:bg-slate-500 [&[data-separator='active']]:bg-slate-400",
2426
"text-slate-900 [&[data-separator='hover']]:text-slate-950 [&[data-separator='active']]:text-slate-950",
25-
"[&[data-separator='focus']]:bg-sky-400",
27+
useFocusPseudoClasses
28+
? "focus-visible:bg-sky-400!"
29+
: "[&[data-separator='focus']]:bg-sky-400",
2630
orientation === "horizontal" ? "w-4 sm:w-2" : "h-4 sm:h-2",
2731
className
2832
)}

src/routes/CustomStylesRoute.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Box, Callout, Code, Header } from "react-lib-tools";
22
import { html as CustomStylesExampleHTML } from "../../public/generated/examples/SeparatorCustomStyles.json";
3+
import { html as SeparatorCustomStylesFocusVisibleHTML } from "../../public/generated/examples/SeparatorCustomStylesFocusVisible.json";
34
import { html as DataAttributesExampleHTML } from "../../public/generated/examples/SeparatorDataAttributes.json";
45
import { Group } from "../components/styled-panels/Group";
56
import { Panel } from "../components/styled-panels/Panel";
@@ -38,6 +39,17 @@ export default function CustomStylesRoute() {
3839
<Separator />
3940
<Panel defaultSize="50%">right</Panel>
4041
</Group>
42+
<div>
43+
If you want to differentiate between keyboard-initiated focus and
44+
pointer-initiated focus, you can use the <code>:focus</code> and{" "}
45+
<code>:focus-visible</code> CSS pseudo-class instead.
46+
</div>
47+
<Code html={SeparatorCustomStylesFocusVisibleHTML} />
48+
<Group>
49+
<Panel>left</Panel>
50+
<Separator useFocusPseudoClasses />
51+
<Panel defaultSize="50%">right</Panel>
52+
</Group>
4153
</Box>
4254
);
4355
}

0 commit comments

Comments
 (0)