From c9e68d2fb010e30fbc0a925282a6cf790176937c Mon Sep 17 00:00:00 2001 From: Tyler Jones Date: Mon, 28 Oct 2024 13:42:02 -0400 Subject: [PATCH 1/6] AvatarStack: Adds back empty space in `AvatarStack` (#5181) * adds back empty space in `AvatarStack` * Update snapshot --- packages/react/src/AvatarStack/AvatarStack.tsx | 1 + .../react/src/__tests__/__snapshots__/AvatarStack.test.tsx.snap | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/react/src/AvatarStack/AvatarStack.tsx b/packages/react/src/AvatarStack/AvatarStack.tsx index 8430fc199b5..ccd87f1e24f 100644 --- a/packages/react/src/AvatarStack/AvatarStack.tsx +++ b/packages/react/src/AvatarStack/AvatarStack.tsx @@ -314,6 +314,7 @@ const AvatarStack = ({ tabIndex={!hasInteractiveChildren && !disableExpand ? 0 : undefined} ref={stackContainer} > + {' '} {transformChildren(children)} diff --git a/packages/react/src/__tests__/__snapshots__/AvatarStack.test.tsx.snap b/packages/react/src/__tests__/__snapshots__/AvatarStack.test.tsx.snap index cc28e33c219..8f68da6c108 100644 --- a/packages/react/src/__tests__/__snapshots__/AvatarStack.test.tsx.snap +++ b/packages/react/src/__tests__/__snapshots__/AvatarStack.test.tsx.snap @@ -188,6 +188,7 @@ exports[`Avatar respects alignRight props 1`] = ` className="pc-AvatarStackBody" tabIndex={0} > + Date: Mon, 28 Oct 2024 14:41:22 -0400 Subject: [PATCH 2/6] Overlay: Add proper roles w/ keyboard expectations to stories (#5175) * Add proper roles w/ keyboard expectations to stories * Make prop optional --- .../src/Overlay/Overlay.features.stories.tsx | 108 ++++++++++++++++-- 1 file changed, 99 insertions(+), 9 deletions(-) diff --git a/packages/react/src/Overlay/Overlay.features.stories.tsx b/packages/react/src/Overlay/Overlay.features.stories.tsx index ac35e8bfc5a..340181ab53c 100644 --- a/packages/react/src/Overlay/Overlay.features.stories.tsx +++ b/packages/react/src/Overlay/Overlay.features.stories.tsx @@ -1,6 +1,6 @@ import React, {useState, useRef, useCallback} from 'react' import type {Meta} from '@storybook/react' -import {TriangleDownIcon, PlusIcon, IssueDraftIcon} from '@primer/octicons-react' +import {TriangleDownIcon, PlusIcon, IssueDraftIcon, XIcon} from '@primer/octicons-react' import { Overlay, ButtonGroup, @@ -16,8 +16,10 @@ import { Label, ActionList, ActionMenu, + useFocusTrap, } from '..' import type {AnchorSide} from '@primer/behaviors' +import type {AriaRole} from '../utils/types' import {Tooltip} from '../TooltipV2' export default { @@ -25,6 +27,7 @@ export default { component: Overlay, args: { anchorSide: 'inside-top', + role: 'dialog', }, argTypes: { anchorSide: { @@ -43,16 +46,22 @@ export default { 'outside-right', ], }, + role: { + type: 'string', + }, }, } as Meta interface OverlayProps { - anchorSide: AnchorSide + anchorSide?: AnchorSide + role?: AriaRole + right?: boolean } export const DropdownOverlay = ({anchorSide}: OverlayProps) => { const [isOpen, setIsOpen] = useState(false) const buttonRef = useRef(null) + return ( <> + )} + open={open} + onOpenChange={setOpen} + items={filteredItems} + selected={selected} + onSelectedChange={setSelected} + onFilterChange={setFilter} + /> + + ) +} + export const WithLeadingVisual = () => ( diff --git a/packages/react/src/FormControl/FormControl.tsx b/packages/react/src/FormControl/FormControl.tsx index 257163c753a..a6ccd15c858 100644 --- a/packages/react/src/FormControl/FormControl.tsx +++ b/packages/react/src/FormControl/FormControl.tsx @@ -4,6 +4,7 @@ import Box from '../Box' import Checkbox from '../Checkbox' import Radio from '../Radio' import Select from '../Select' +import {SelectPanel} from '../SelectPanel' import TextInput from '../TextInput' import TextInputWithTokens from '../TextInputWithTokens' import Textarea from '../Textarea' @@ -50,7 +51,16 @@ const FormControl = React.forwardRef( leadingVisual: FormControlLeadingVisual, validation: FormControlValidation, }) - const expectedInputComponents = [Autocomplete, Checkbox, Radio, Select, TextInput, TextInputWithTokens, Textarea] + const expectedInputComponents = [ + Autocomplete, + Checkbox, + Radio, + Select, + TextInput, + TextInputWithTokens, + Textarea, + SelectPanel, + ] const choiceGroupContext = useContext(CheckboxOrRadioGroupContext) const disabled = choiceGroupContext.disabled || disabledProp const id = useId(idProp)