-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: multiselect relationship bug and improve accessibility (#6286)
## Description Closes [#117](payloadcms/payload-3.0-demo#177) - hitting the space key while the `ReactSelect` is in focus crashes the page. This PR makes the following changes: - Multivalue select component updated to only use `id`, drag feature does not work when using `uuid()` - Ensures relationship field (multi and single value) can be accessed via the keyboard - [X] I have read and understand the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository. ## Type of change - [X] Bug fix (non-breaking change which fixes an issue) ## Checklist: - [X] Existing test suite passes locally with my changes
- Loading branch information
1 parent
0e9bbec
commit 5a4074e
Showing
14 changed files
with
106 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,8 @@ | |
|
||
.clear-indicator { | ||
cursor: pointer; | ||
|
||
&:focus-visible { | ||
outline: var(--accessibility-outline); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/ui/src/elements/ReactSelect/DropdownIndicator/index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@import '../../../scss/styles.scss'; | ||
|
||
.dropdown-indicator { | ||
cursor: pointer; | ||
@include btn-reset; | ||
|
||
&:focus-visible { | ||
outline: var(--accessibility-outline); | ||
} | ||
|
||
&__icon { | ||
.stroke { | ||
stroke-width: 1px; | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/ui/src/elements/ReactSelect/DropdownIndicator/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { DropdownIndicatorProps } from 'react-select' | ||
|
||
import { Chevron } from '@payloadcms/ui/icons/Chevron' | ||
import React from 'react' | ||
|
||
import type { Option as OptionType } from '../types.js' | ||
|
||
import './index.scss' | ||
|
||
const baseClass = 'dropdown-indicator' | ||
export const DropdownIndicator: React.FC< | ||
DropdownIndicatorProps<OptionType, true> & { | ||
innerProps: JSX.IntrinsicElements['button'] | ||
} | ||
> = (props) => { | ||
const { | ||
innerProps: { ref, ...restInnerProps }, | ||
} = props | ||
|
||
return ( | ||
<button | ||
className={baseClass} | ||
ref={ref} | ||
{...restInnerProps} | ||
onKeyDown={(e) => { | ||
if (e.key === 'Enter') e.key = ' ' | ||
}} | ||
type="button" | ||
> | ||
<Chevron className={`${baseClass}__icon`} /> | ||
</button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,8 @@ | |
overflow: hidden; | ||
white-space: nowrap; | ||
} | ||
|
||
&:focus-visible { | ||
outline: var(--accessibility-outline); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters