From 63b7770220d16ccadf190ec998506a9aadb7056b Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 4 Feb 2022 12:38:39 +0100 Subject: [PATCH] Accessibility: Fix text selection when using FocusScope (#44770) (#44902) * Add tabIndex={-1} to places using focusScope to allow for text highlighting * use useDialog * don't need explicit tabIndex anymore * remove duplicate spreading of props (cherry picked from commit 9e52361c1e837fc78d15458fe6fc4c23d4d7c09b) Co-authored-by: Ashley Harrison --- package.json | 1 + packages/grafana-ui/package.json | 1 + .../ColorPicker/ColorPickerPopover.tsx | 10 ++- .../DateTimePickers/TimeRangePicker.tsx | 4 +- .../TimeRangePicker/CalendarBody.tsx | 4 + .../TimeRangePicker/TimePickerCalendar.tsx | 17 ++-- .../src/components/Drawer/Drawer.tsx | 78 ++++++++++--------- .../src/components/Dropdown/ButtonSelect.tsx | 6 +- .../grafana-ui/src/components/Modal/Modal.tsx | 6 +- .../NavBar/NavBarItemMenuTrigger.tsx | 4 +- .../app/core/components/NavBar/NavBarMenu.tsx | 4 +- .../editors/ResourcePickerPopover.tsx | 4 +- .../plugins/panel/geomap/GeomapTooltip.tsx | 4 +- yarn.lock | 31 +++++++- 14 files changed, 120 insertions(+), 54 deletions(-) diff --git a/package.json b/package.json index 2698218ff20..dcc19b532d5 100644 --- a/package.json +++ b/package.json @@ -248,6 +248,7 @@ "@opentelemetry/semantic-conventions": "1.0.1", "@popperjs/core": "2.11.2", "@react-aria/button": "3.3.4", + "@react-aria/dialog": "3.1.4", "@react-aria/focus": "3.5.0", "@react-aria/interactions": "3.7.0", "@react-aria/menu": "3.3.0", diff --git a/packages/grafana-ui/package.json b/packages/grafana-ui/package.json index d74d6fcdfe1..9cb033b7265 100644 --- a/packages/grafana-ui/package.json +++ b/packages/grafana-ui/package.json @@ -40,6 +40,7 @@ "@monaco-editor/react": "4.3.1", "@popperjs/core": "2.11.2", "@react-aria/button": "3.3.4", + "@react-aria/dialog": "3.1.4", "@react-aria/focus": "3.5.0", "@react-aria/menu": "3.3.0", "@react-aria/overlays": "3.7.3", diff --git a/packages/grafana-ui/src/components/ColorPicker/ColorPickerPopover.tsx b/packages/grafana-ui/src/components/ColorPicker/ColorPickerPopover.tsx index ff99b57c90e..84767c4fb92 100644 --- a/packages/grafana-ui/src/components/ColorPicker/ColorPickerPopover.tsx +++ b/packages/grafana-ui/src/components/ColorPicker/ColorPickerPopover.tsx @@ -104,9 +104,9 @@ class UnThemedColorPickerPopover extends Reac <> {Object.keys(customPickers).map((key) => { return ( -
+
+ ); })} @@ -118,7 +118,11 @@ class UnThemedColorPickerPopover extends Reac const styles = getStyles(theme); return ( -
+ {/* + tabIndex=-1 is needed here to support highlighting text within the picker when using FocusScope + see https://github.com/adobe/react-spectrum/issues/1604#issuecomment-781574668 + */} +