Skip to content

Commit 973ebab

Browse files
committed
Render radio icons on single select modal select panel
1 parent a76b712 commit 973ebab

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

packages/react/src/ActionList/ActionList.module.css

+4
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@
409409
visibility: hidden;
410410
}
411411

412+
.SingleSelectRadio {
413+
margin-right: var(--base-size-8);
414+
}
415+
412416
/* button or a tag */
413417

414418
/* [ [spacer] [leadingAction] [leadingVisual] [content] ] */

packages/react/src/ActionList/Selection.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Box from '../Box'
88
import {useFeatureFlag} from '../FeatureFlags'
99
import classes from './ActionList.module.css'
1010
import {actionListCssModulesFlag} from './featureflag'
11+
import Radio from '../Radio'
1112

1213
type SelectionProps = Pick<ActionListItemProps, 'selected' | 'className'>
1314
export const Selection: React.FC<React.PropsWithChildren<SelectionProps>> = ({selected, className}) => {
@@ -34,6 +35,17 @@ export const Selection: React.FC<React.PropsWithChildren<SelectionProps>> = ({se
3435
}
3536
}
3637

38+
if (selectionVariant === 'radio') {
39+
return (
40+
<VisualContainer className={className}>
41+
{/* This is just a way to get the visuals from Radio, but it should be ignored in terms of accessibility */}
42+
<div aria-hidden="true">
43+
<Radio className={classes.SingleSelectRadio} value="unused" checked={selected} />
44+
</div>
45+
</VisualContainer>
46+
)
47+
}
48+
3749
if (selectionVariant === 'single' || listRole === 'menu') {
3850
if (enabled) {
3951
return (

packages/react/src/ActionList/shared.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export type ActionListProps = React.PropsWithChildren<{
124124
/**
125125
* Whether multiple Items or a single Item can be selected.
126126
*/
127-
selectionVariant?: 'single' | 'multiple'
127+
selectionVariant?: 'single' | 'radio' | 'multiple'
128128
/**
129129
* Display a divider above each `Item` in this `List` when it does not follow a `Header` or `Divider`.
130130
*/

packages/react/src/SelectPanel/SelectPanel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ export function SelectPanel({
545545
// we don't accidentally override props.aria-label
546546
aria-labelledby={listProps['aria-label'] ? undefined : titleId}
547547
aria-multiselectable={isMultiSelectVariant(selected) ? 'true' : 'false'}
548-
selectionVariant={isMultiSelectVariant(selected) ? 'multiple' : 'single'}
548+
selectionVariant={isSingleSelectModal ? 'radio' : isMultiSelectVariant(selected) ? 'multiple' : 'single'}
549549
items={itemsToRender}
550550
textInputProps={extendedTextInputProps}
551551
loading={loading || isLoading}

packages/react/src/deprecated/ActionList/Item.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export interface ItemProps extends SxProp {
8484
/**
8585
* For `Item`s which can be selected, whether `multiple` `Item`s or a `single` `Item` can be selected
8686
*/
87-
selectionVariant?: 'single' | 'multiple'
87+
selectionVariant?: 'single' | 'multiple' | 'radio'
8888

8989
/**
9090
* Designates the group that an item belongs to.

packages/react/src/deprecated/ActionList/List.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export interface ListPropsBase {
6767
/**
6868
* For `Item`s which can be selected, whether `multiple` `Item`s or a `single` `Item` can be selected
6969
*/
70-
selectionVariant?: 'single' | 'multiple'
70+
selectionVariant?: 'single' | 'multiple' | 'radio'
7171

7272
/**
7373
* Whether to display a divider above each `Item` in this `List` when it does not follow a `Header` or `Divider`.

0 commit comments

Comments
 (0)