-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds FormControl's "Auto-Wiring" to SelectPanel v2 Component #4389
Merged
siddharthkp
merged 21 commits into
main
from
jeffreykozik/autolinking_selectpanelv2_to_formcontrol
Apr 24, 2024
Merged
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0f4cec5
autowires SelectPanelv2 to FormControl
JeffreyKozik 06b048a
added changeset
JeffreyKozik 5e46bce
Update afraid-beds-lick.md
siddharthkp d1df0dd
Button is aria-labelledby by 2 different components now
JeffreyKozik 3d69e09
using querySelector instead of VisuallyHidden approach
JeffreyKozik 969c97c
Merge branch 'main' into jeffreykozik/autolinking_selectpanelv2_to_fo…
JeffreyKozik 4d7b5d7
Added visually hidden punctuation
JeffreyKozik 616ad2b
removed selectPanelButtonId
JeffreyKozik d26d79a
hiding visuallyhidden text from screen readers as well
JeffreyKozik d6b08a2
use ariaLabel instead of ariaLabelledby
JeffreyKozik 6ea27c7
added a 2nd test for complex button case
JeffreyKozik 006a61b
updated tests
JeffreyKozik e8aa873
Merge branch 'main' into jeffreykozik/autolinking_selectpanelv2_to_fo…
JeffreyKozik 672aaab
using aria-labelledby to reference itself, updated tests
JeffreyKozik c3e1594
flipped order within aria-label
JeffreyKozik 71ea3b5
updated conditional, added negative test
JeffreyKozik a3db265
Merge branch 'main' into jeffreykozik/autolinking_selectpanelv2_to_fo…
JeffreyKozik e6d93e1
removed aria-labelledby
JeffreyKozik 38d9748
Merge branch 'main' into jeffreykozik/autolinking_selectpanelv2_to_fo…
JeffreyKozik 856e957
test
JeffreyKozik eacfa7c
fix
JeffreyKozik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/react': minor | ||
--- | ||
|
||
Automatically wires the SelectPanel v2 component to the accessibility and validation provided by the FormControl component it's nested within. If SelectPanel v2 isn't nested within FormControl, nothing changes. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,20 @@ import {SearchIcon, XCircleFillIcon, XIcon, FilterRemoveIcon, AlertIcon, ArrowLe | |
import {FocusKeys} from '@primer/behaviors' | ||
|
||
import type {ButtonProps, TextInputProps, ActionListProps, LinkProps, CheckboxProps} from '../../index' | ||
import {Button, IconButton, Heading, Box, Tooltip, TextInput, Spinner, Text, Octicon, Link, Checkbox} from '../../index' | ||
import { | ||
Button, | ||
IconButton, | ||
Heading, | ||
Box, | ||
Tooltip, | ||
TextInput, | ||
Spinner, | ||
Text, | ||
Octicon, | ||
Link, | ||
Checkbox, | ||
useFormControlForwardedProps, | ||
} from '../../index' | ||
import {ActionListContainerContext} from '../../ActionList/ActionListContainerContext' | ||
import {useSlots} from '../../hooks/useSlots' | ||
import {useProvidedRefOrCreate, useId, useAnchoredPosition} from '../../hooks' | ||
|
@@ -315,7 +328,8 @@ const Panel: React.FC<SelectPanelProps> = ({ | |
} | ||
|
||
const SelectPanelButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, anchorRef) => { | ||
return <Button ref={anchorRef} {...props} /> | ||
const inputProps = useFormControlForwardedProps(props) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Followed the pattern suggested in this slack thread: https://github.slack.com/archives/CSGAVNZ19/p1709843761424779?thread_ts=1709836721.563139&cid=CSGAVNZ19 |
||
return <Button ref={anchorRef} {...inputProps} /> | ||
}) | ||
|
||
const SelectPanelHeader: React.FC<React.PropsWithChildren & {onBack?: () => void}> = ({children, onBack, ...props}) => { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the hook recently created by @iansan5653 in this PR: #3632. This hook is also being used in the
InlineAutocomplete
draft component:react/packages/react/src/drafts/InlineAutocomplete/InlineAutocomplete.tsx
Line 118 in cb54f42