Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {vars} from './skins/skin-contract.css';
import {applyCssVars} from './utils/css';
import {IconButton, ToggleIconButton} from './icon-button';
import ScreenReaderOnly from './screen-reader-only';
import Spinner from './spinner';

import type {IconButtonProps, ToggleIconButtonProps} from './icon-button';
import type {TouchableElement, TouchableProps} from './touchable';
Expand Down Expand Up @@ -260,6 +261,9 @@ type ControlProps = {
value?: boolean;
defaultValue?: boolean;
onChange?: (checked: boolean) => void;
updatingValue?: {
showSpinner: boolean;
};
};

type BasicRowContentProps = CommonProps;
Expand Down Expand Up @@ -443,22 +447,22 @@ const RowContent = React.forwardRef<TouchableElement, RowContentProps>((props, r
descriptionLinesMax={descriptionLinesMax}
detail={detail}
danger={danger}
right={right}
right={props.switch?.updatingValue?.showSpinner ? <Spinner /> : undefined}
rightRef={(node) => {
if (node) {
// jsdom doesn't support innerText so we fallback to textContent https://github.com/jsdom/jsdom/issues/1245
setRightText(node.innerText || node.textContent || '');
}
}}
control={contentProps?.control}
control={props.switch?.updatingValue?.showSpinner ? undefined : contentProps?.control}
extra={extra}
extraRef={(node) => {
if (node) {
setExtraText(node.innerText || node.textContent || '');
}
}}
labelId={contentProps?.labelId}
disabled={disabled}
disabled={disabled || props.switch?.updatingValue !== undefined}
withChevron={hasChevron}
/>
);
Expand Down Expand Up @@ -537,6 +541,7 @@ const RowContent = React.forwardRef<TouchableElement, RowContentProps>((props, r
aria-label={ariaLabel}
aria-labelledby={titleId}
onChange={toggle}
aria-busy={props.switch?.updatingValue !== undefined}
render={({controlElement}) => (
<div className={styles.dualActionRight}>{controlElement}</div>
)}
Expand All @@ -549,6 +554,7 @@ const RowContent = React.forwardRef<TouchableElement, RowContentProps>((props, r
checked={isChecked}
aria-label={ariaLabel}
aria-labelledby={titleId}
aria-busy={props.switch?.updatingValue !== undefined}
onChange={toggle}
render={({controlElement, labelId}) => (
<Box paddingX={16} role={role}>
Expand Down
3 changes: 3 additions & 0 deletions src/switch-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type PropsRender = {
children?: undefined;
'aria-labelledby'?: string;
'aria-label'?: string;
'aria-busy'?: boolean;
dataAttributes?: DataAttributes;
};

Expand All @@ -48,6 +49,7 @@ type PropsChildren = {
render?: undefined;
'aria-labelledby'?: string;
'aria-label'?: string;
'aria-busy'?: boolean;
dataAttributes?: DataAttributes;
};

Expand Down Expand Up @@ -140,6 +142,7 @@ const Switch = (props: PropsRender | PropsChildren): JSX.Element => {
<span
role="switch"
aria-checked={value ?? checkedState}
aria-busy={props['aria-busy']}
onClick={(e) => {
e.stopPropagation();
if (!disabled) {
Expand Down
Loading