feat: add accessibility support to loading state components#388
feat: add accessibility support to loading state components#388adrienzheng-cb wants to merge 3 commits intomasterfrom
Conversation
🟡 Heimdall Review Status
🟡
|
| Code Owner | Status | Calculation | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ui-systems-eng-team |
🟡
0/1
|
Denominator calculation
|
| }; | ||
|
|
||
| export type LottieBaseProps<T extends LottieSource = LottieSource> = Omit< | ||
| BoxBaseProps, |
There was a problem hiding this comment.
only optional new props are added, non-breaking
| const animatedProgress = useRef(new Animated.Value(previousPercent)); | ||
|
|
||
| const [innerWidth, setInnerWidth] = useState<number>(-1); | ||
| const [trackWidth, setTrackWidth] = useState<number>(-1); |
There was a problem hiding this comment.
changed to more accurate variable name
| const onAnimationEndRef = useRef(onAnimationEnd); | ||
| const onAnimationStartRef = useRef(onAnimationStart); | ||
| onAnimationEndRef.current = onAnimationEnd; | ||
| onAnimationStartRef.current = onAnimationStart; |
There was a problem hiding this comment.
ensure the ref is up-to-date whenever component rerenders. we should switch to useEffectCallback after react 19
| testID, | ||
| accessibilityLabel, | ||
| ...otherProps | ||
| }: LottieStatusAnimationProps & { accessibilityLabel?: string }) => { |
There was a problem hiding this comment.
I wonder if we missed bringing this to web and mobile during v8 migration.
You think we would be better off here bringing this into mobile and web? Also we could do
import { LottieStatusAnimationProps as CommonLottieStatusAnimationProps, SharedAccessibilityProps } from ...
type LottieStatusAnimationProps = CommonLottieStatusAnimationProps & {
/**
* Accessibility label shown along with the current state
* @default 'Loading' when loading, ... (or whatever you want to say)
*/
accessibilityLabel?: SharedAccessibilityProps['accessibilityLabel'];
}
This way people would know to override for i18n as well.
There was a problem hiding this comment.
I thought v8 was trying to get away from defining common props in common package
There was a problem hiding this comment.
Yep that's why I'm surprised we missed this in v8.
| /** When true, indicates that the view is an accessibility element */ | ||
| accessible?: boolean; | ||
| /** A string value that labels an interactive element for VoiceOver */ | ||
| accessibilityLabel?: string; |
There was a problem hiding this comment.
Nit: could we pull from SharedAccessibilityProps or from BoxProps?
There was a problem hiding this comment.
I attempted to do that, but it does not include role or aria-live prop :(.
There was a problem hiding this comment.
Could we do LottieBaseProps<...> = Pick<SharedAccessibilityProps, 'accessibilityLabel> & ...?
I'm not seeing role or aria-live in this spot, I know I saw it elsewhere
| import type { Polymorphic } from '../core/polymorphism'; | ||
|
|
||
| import { Box, type BoxBaseProps } from './Box'; | ||
|
|
There was a problem hiding this comment.
updated to use the same useFallbackShape hook and type defined in common
| /** | ||
| * A boolean flag indicating whether or not the animation should start automatically when | ||
| * mounted. This only affects the imperative API. | ||
| * @default false |
There was a problem hiding this comment.
nit: could we remove these falsy defaults
|
|
||
| Fallback.displayName = 'Fallback'; | ||
|
|
||
| export { useFallbackShape, type UseFallbackShapeOptions }; |
There was a problem hiding this comment.
re-export them for backward-compatibility
| hexagon: css` | ||
| border-radius: 0; | ||
| border-radius: ${shapeBorderRadius.hexagon}px; | ||
| `, |
There was a problem hiding this comment.
remove hardcoded borderRadius value
| const onAnimationEndRef = useRef(onAnimationEnd); | ||
| const onAnimationStartRef = useRef(onAnimationStart); | ||
| onAnimationEndRef.current = onAnimationEnd; | ||
| onAnimationStartRef.current = onAnimationStart; |
There was a problem hiding this comment.
What exactly was happening in your tests here?
packages/web/src/animation/types.ts
Outdated
| role?: AriaRole; | ||
| /** ARIA live region setting for dynamic content announcements */ | ||
| 'aria-live'?: AriaAttributes['aria-live']; | ||
| }; |
There was a problem hiding this comment.
Do we want to include this as a separate type? Is this being used elsewhere or only in this file?
| import React from 'react'; | ||
| import type { LottieStatusAnimationProps } from '@coinbase/cds-common'; | ||
| import React, { memo, useMemo } from 'react'; | ||
| import type { LottieStatusAnimationProps, LottieStatusAnimationType } from '@coinbase/cds-common'; |
There was a problem hiding this comment.
Do we want to mark LottieStatusAnimationProps as deprecated in common and then not reuse it but instead re-define here in mobile and web?
Accessibility improvements: - Add role="status", aria-live="polite", and accessibilityLabel to Fallback, Spinner, and LottieStatusAnimation on web and mobile - LottieStatusAnimation auto-generates labels based on status - Update Fallback docs with accessibility guidance and grouping examples Bug fixes: - Fix ProgressBar callback re-animation issue by storing callbacks in refs instead of including them in useEffect dependencies Test improvements: - Add shape, width variant, and accessibility tests for Fallback - Add size variant and accessibility tests for Spinner - Add cardSuccess and status transition tests for LottieStatusAnimation Refactoring: - Move useFallbackShape hook to @coinbase/cds-common for cross-platform use - Use shapeBorderRadius tokens in RemoteImage/RemoteImageGroup - Add LottieAccessibilityProps types to animation types Also includes auto-generated icon updates (autoCar, birthcertificate, webhooks) and pencil icon active/inactive swap fix. Co-authored-by: Cursor <cursoragent@cursor.com>
a0c602c to
f7567c4
Compare
Accessibility improvements:
Bug fixes:
Test improvements:
Refactoring:
Also includes auto-generated icon updates (autoCar, birthcertificate, webhooks) and pencil icon active/inactive swap fix.
What changed? Why?
Root cause (required for bugfixes)
UI changes
Testing
How has it been tested?
Testing instructions
Illustrations/Icons Checklist
Required if this PR changes files under
packages/illustrations/**orpackages/icons/**Change management
type=routine
risk=low
impact=sev5
automerge=false