Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 677
SelectPanel: Add variant=modal#5198
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
f7c39eaf31034f87b84ee36f029eef139373816a96e72d3332e5a623987f189bc9a6c9d165dae667fb54ca5f714f8d47e953ff7ba859019ee427df0fca7e79f0be4801b7b968679f5d0d7b28be5db37aa2c92a4f7c178bd43aaf3f2a14113fdc0bd4File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -29,23 +29,25 @@ interface SelectPanelMultiSelection { | ||
| onSelectedChange: (selected: ItemInput[]) => void | ||
| } | ||
| type OpenGestures = 'anchor-click' | 'anchor-key-press' | ||
Member 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. ❤️ | ||
| type CloseGestures = 'click-outside' | 'escape' | 'selection' | 'save-click' | 'cancel-click' | ||
| interface SelectPanelBaseProps { | ||
| // TODO: Make `title` required in the next major version | ||
| title?: string | React.ReactElement | ||
| subtitle?: string | React.ReactElement | ||
| onOpenChange: ( | ||
| open: boolean, | ||
| gesture: 'anchor-click' | 'anchor-key-press' | 'click-outside' | 'escape' | 'selection', | ||
| ) => void | ||
| onOpenChange: (open: boolean, gesture: OpenGestures | CloseGestures) => void | ||
| placeholder?: string | ||
| // TODO: Make `inputLabel` required in next major version | ||
| inputLabel?: string | ||
| overlayProps?: Partial<OverlayProps> | ||
| footer?: string | React.ReactElement | ||
| // TODO: do we need keep the old variants for backward-compat? there isn't any usage in dotcom | ||
| variant?: 'anchored' | 'modal' | FilteredActionListProps['variant'] | ||
| } | ||
| export type SelectPanelProps = SelectPanelBaseProps & | ||
| Omit<FilteredActionListProps, 'selectionVariant'> & | ||
| Omit<FilteredActionListProps, 'selectionVariant' | 'variant'> & | ||
| Pick<AnchoredOverlayProps, 'open'> & | ||
| AnchoredOverlayWrapperAnchorProps & | ||
| (SelectPanelSingleSelection | SelectPanelMultiSelection) | ||
| @@ -90,7 +92,8 @@ export function SelectPanel({ | ||
| items, | ||
| footer, | ||
| textInputProps, | ||
| overlayProps, | ||
| variant = 'anchored', | ||
| overlayProps = variant === 'modal' ? {maxWidth: 'medium', height: 'fit-content', maxHeight: 'large'} : undefined, | ||
| sx, | ||
| ...listProps | ||
| }: SelectPanelProps): JSX.Element { | ||
| @@ -111,12 +114,16 @@ export function SelectPanel({ | ||
| [onOpenChange], | ||
| ) | ||
| const onClose = useCallback( | ||
| (gesture: Parameters<Exclude<AnchoredOverlayProps['onClose'], undefined>>[0] | 'selection') => { | ||
| (gesture: Parameters<Exclude<AnchoredOverlayProps['onClose'], undefined>>[0] | CloseGestures) => { | ||
| onOpenChange(false, gesture) | ||
| }, | ||
| [onOpenChange], | ||
| ) | ||
| const onCancel = () => { | ||
| // TODO | ||
| } | ||
| const renderMenuAnchor = useMemo(() => { | ||
| if (renderAnchor === null) { | ||
| return null | ||
| @@ -256,8 +263,19 @@ export function SelectPanel({ | ||
| /* this is required so that clicking the button while the panel is open does not re-open the panel */ | ||
| [anchorRef] | ||
| } | ||
| {...position} | ||
| data-variant={variant} | ||
| {...overlayProps} | ||
| {...(variant === 'anchored' ? position : {})} | ||
| sx={{ | ||
| '&[data-variant="anchored"]': { | ||
| margin: 0, | ||
| }, | ||
| '&[data-variant="modal"]': { | ||
| position: 'fixed', | ||
| inset: 0, | ||
| margin: 'auto', | ||
| }, | ||
| }} | ||
| > | ||
| <LiveRegionOutlet /> | ||
| {usingModernActionList ? null : ( | ||
| @@ -300,20 +318,56 @@ export function SelectPanel({ | ||
| // than the Overlay (which would break scrolling the items) | ||
| sx={{...sx, height: 'inherit', maxHeight: 'inherit'}} | ||
| /> | ||
| {footer && ( | ||
| {footer || variant === 'modal' ? ( | ||
| <Box | ||
| sx={{ | ||
| display: 'flex', | ||
| borderTop: '1px solid', | ||
| borderColor: 'border.default', | ||
| padding: 2, | ||
| padding: variant === 'modal' ? 3 : 2, | ||
| justifyContent: footer ? 'space-between' : 'end', | ||
| alignItems: 'center', | ||
| flexShrink: 0, | ||
| minHeight: '44px', | ||
| '> button': { | ||
| // make button full width if there's just one | ||
| width: variant === 'modal' ? 'auto' : '100%', | ||
| }, | ||
| }} | ||
| > | ||
| {footer} | ||
| {variant === 'modal' ? ( | ||
| <Box sx={{display: 'flex', gap: 2}}> | ||
| <Button | ||
| type="button" | ||
| size="small" | ||
| onClick={() => { | ||
| onCancel() | ||
| onClose('cancel-click') | ||
| }} | ||
| > | ||
| Cancel | ||
| </Button> | ||
| {/* TODO: loading state for save? */} | ||
| <Button type="submit" size="small" variant="primary" onClick={() => onClose('save-click')}> | ||
| Save | ||
| </Button> | ||
| </Box> | ||
| ) : null} | ||
| </Box> | ||
| )} | ||
| ) : null} | ||
| </Box> | ||
| </Overlay> | ||
| {variant === 'modal' && ( | ||
| <Box | ||
| data-backdrop | ||
| sx={{ | ||
| backgroundColor: 'primer.canvas.backdrop', | ||
| position: 'fixed', | ||
| inset: 0, | ||
| }} | ||
| /> | ||
| )} | ||
| </LiveRegion> | ||
| ) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
non blocking improvement 1/2: While footer is backward compatible, it's not obvious what it means. What we want here is a "secondary action".
Looking at usage (3 instances), we have