-
Notifications
You must be signed in to change notification settings - Fork 538
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
Selectpanel2: Remove SelectPanel.ActionList API #3764
Changes from 42 commits
080351c
445e150
3b36ae0
f14d727
c7ed2d7
6296f32
7350510
a5dbe92
2f12c35
8413f74
a7208c3
39f6779
7689c7f
7ce02ba
796effe
88f27e5
6fc2508
dd17537
d774dd8
5dd2853
211d5ba
4720653
ba07364
a4197ad
1420edc
be44380
d34ca0a
0d08c01
a7fa2d9
9bf52b9
6753461
6011cc6
40d3c57
8e00e7f
02901a8
279e846
eed8da1
f046646
9f8cf08
d1c872b
283f800
332e132
7e8b46a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -38,7 +38,12 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>( | |||||||
trailingVisual: TrailingVisual, | ||||||||
description: Description, | ||||||||
}) | ||||||||
const {variant: listVariant, showDividers, selectionVariant: listSelectionVariant} = React.useContext(ListContext) | ||||||||
const { | ||||||||
variant: listVariant, | ||||||||
role: listRole, | ||||||||
showDividers, | ||||||||
selectionVariant: listSelectionVariant, | ||||||||
} = React.useContext(ListContext) | ||||||||
const {selectionVariant: groupSelectionVariant} = React.useContext(GroupContext) | ||||||||
const {container, afterSelect, selectionAttribute} = React.useContext(ActionListContainerContext) | ||||||||
|
||||||||
|
@@ -65,6 +70,8 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>( | |||||||
if (selectionVariant === 'single') itemRole = 'menuitemradio' | ||||||||
else if (selectionVariant === 'multiple') itemRole = 'menuitemcheckbox' | ||||||||
else itemRole = 'menuitem' | ||||||||
} else if (container === 'SelectPanel' && listRole === 'listbox') { | ||||||||
if (selectionVariant !== undefined) itemRole = 'option' | ||||||||
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. This looks like a potentially breaking change, buuut, we never override role: props.role || itemRole Lines 213 to 215 in ba07364
Side note: We could probably apply these without a container as well, but I'd like to test that out separately in dotcom. Keeping the scope tight in this PR. |
||||||||
} | ||||||||
|
||||||||
const {theme} = useTheme() | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,10 @@ import { | |
Tooltip, | ||
TextInput, | ||
AnchoredOverlayProps, | ||
ActionList, | ||
ActionListProps, | ||
Spinner, | ||
Text, | ||
} from '../../../src/index' | ||
import {ActionListContainerContext} from '../../../src/ActionList/ActionListContainerContext' | ||
import {useSlots} from '../../hooks/useSlots' | ||
import {ClearIcon} from './tmp-ClearIcon' | ||
import {useProvidedRefOrCreate} from '../../hooks' | ||
|
@@ -55,13 +54,13 @@ const SelectPanel = props => { | |
React.useEffect(() => setInternalOpen(props.open), [props.open]) | ||
|
||
const onInternalClose = () => { | ||
if (props.open === 'undefined') setInternalOpen(false) | ||
if (props.open === undefined) setInternalOpen(false) | ||
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. Oops I didn't catch that in the previous PR too 😬 |
||
if (typeof props.onCancel === 'function') props.onCancel() | ||
} | ||
// @ts-ignore todo | ||
const onInternalSubmit = event => { | ||
event.preventDefault() | ||
if (props.open === 'undefined') setInternalOpen(false) | ||
if (props.open === undefined) setInternalOpen(false) | ||
if (typeof props.onSubmit === 'function') props.onSubmit(event) | ||
} | ||
|
||
|
@@ -100,12 +99,41 @@ const SelectPanel = props => { | |
setSearchQuery, | ||
}} | ||
> | ||
<Box as="form" onSubmit={onInternalSubmit} sx={{display: 'flex', flexDirection: 'column', height: '100%'}}> | ||
<Box | ||
as="form" | ||
onSubmit={onInternalSubmit} | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
height: '100%', | ||
}} | ||
> | ||
{/* render default header as fallback */} | ||
{slots.header || <SelectPanel.Header />} | ||
{childrenInBody} | ||
{/* render default footer as fallback */} | ||
{slots.footer || <SelectPanel.Footer />} | ||
<Box | ||
sx={{ | ||
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. moved the styles from SelectPanel.ActionList here |
||
flexShrink: 1, | ||
flexGrow: 1, | ||
overflow: 'hidden', | ||
|
||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'space-between', | ||
ul: {overflowY: 'auto', flexGrow: 1}, | ||
}} | ||
> | ||
<ActionListContainerContext.Provider | ||
value={{ | ||
container: 'SelectPanel', | ||
listRole: 'listbox', | ||
selectionAttribute: 'aria-selected', | ||
Comment on lines
+128
to
+129
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. From what I understand, the role is always going to be 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. Yep, that is always true :) |
||
selectionVariant: props.selectionVariant || 'multiple', | ||
}} | ||
> | ||
{childrenInBody} | ||
</ActionListContainerContext.Provider> | ||
</Box> | ||
{slots.footer} | ||
</Box> | ||
</SelectPanelContext.Provider> | ||
</AnchoredOverlay> | ||
|
@@ -215,25 +243,6 @@ const SelectPanelSearchInput = props => { | |
} | ||
SelectPanel.SearchInput = SelectPanelSearchInput | ||
|
||
const SelectPanelActionList: React.FC<React.PropsWithChildren<ActionListProps>> = props => { | ||
/* features to implement for uncontrolled: | ||
1. select | ||
2. sort | ||
3. divider | ||
4. search | ||
5. different results view | ||
*/ | ||
|
||
return ( | ||
<> | ||
<ActionList sx={{flexShrink: 1, flexGrow: 1, overflowY: 'auto'}} selectionVariant="multiple" {...props}> | ||
{props.children} | ||
</ActionList> | ||
</> | ||
) | ||
} | ||
SelectPanel.ActionList = SelectPanelActionList | ||
|
||
const SelectPanelFooter = ({...props}) => { | ||
const {onCancel} = React.useContext(SelectPanelContext) | ||
|
||
|
@@ -277,7 +286,7 @@ const SelectPanelLoading: React.FC<{children: string}> = ({children = 'Fetching | |
flexDirection: 'column', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
flexGrow: 1, | ||
height: '100%', | ||
gap: 3, | ||
}} | ||
> | ||
|
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.
i guess we're not removing this 😇