Skip to content

Commit 31c81da

Browse files
authoredMar 3, 2023
Update useTagGroup and useTag returned prop names (adobe#4156)
* update taggroup api to better reflect roles * change gridRowProps to rowProps
1 parent 9eb8796 commit 31c81da

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed
 

‎packages/@react-aria/tag/src/useTag.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export interface TagAria {
2626
/** Props for the tag visible label (if any). */
2727
labelProps: DOMAttributes,
2828
/** Props for the tag cell element. */
29-
tagProps: DOMAttributes,
29+
gridCellProps: DOMAttributes,
3030
/** Props for the tag row element. */
31-
tagRowProps: DOMAttributes,
31+
rowProps: DOMAttributes,
3232
/** Props for the tag clear button. */
3333
clearButtonProps: AriaButtonProps
3434
}
@@ -78,12 +78,12 @@ export function useTag<T>(props: TagProps<T>, state: TagGroupState<T>, ref: RefO
7878
labelProps: {
7979
id: labelId
8080
},
81-
tagRowProps: {
81+
rowProps: {
8282
...rowProps,
8383
tabIndex: (isFocused || state.selectionManager.focusedKey == null) ? 0 : -1,
8484
onKeyDown: allowsRemoving ? onKeyDown : null
8585
},
86-
tagProps: mergeProps(domProps, gridCellProps, {
86+
gridCellProps: mergeProps(domProps, gridCellProps, {
8787
'aria-errormessage': props['aria-errormessage'],
8888
'aria-label': props['aria-label']
8989
})

‎packages/@react-aria/tag/src/useTagGroup.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {useLocale} from '@react-aria/i18n';
2323

2424
export interface TagGroupAria {
2525
/** Props for the tag grouping element. */
26-
tagGroupProps: DOMAttributes,
26+
gridProps: DOMAttributes,
2727
/** Props for the tag group's visible label (if any). */
2828
labelProps: DOMAttributes,
2929
/** Props for the tag group description element, if any. */
@@ -62,7 +62,7 @@ export function useTagGroup<T>(props: AriaTagGroupProps<T>, state: TagGroupState
6262
});
6363
let domProps = filterDOMProps(props);
6464
return {
65-
tagGroupProps: mergeProps(gridProps, domProps, {
65+
gridProps: mergeProps(gridProps, domProps, {
6666
role: state.collection.size ? 'grid' : null,
6767
'aria-atomic': false,
6868
'aria-relevant': 'additions',

‎packages/@react-spectrum/tag/src/Tag.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function Tag<T>(props: SpectrumTagProps<T>) {
4141
let {hoverProps, isHovered} = useHover({});
4242
let {isFocused, isFocusVisible, focusProps} = useFocusRing({within: true});
4343
let ref = useRef();
44-
let {clearButtonProps, labelProps, tagProps, tagRowProps} = useTag({
44+
let {clearButtonProps, labelProps, gridCellProps, rowProps} = useTag({
4545
...props,
4646
isFocused,
4747
allowsRemoving,
@@ -51,7 +51,7 @@ export function Tag<T>(props: SpectrumTagProps<T>) {
5151

5252
return (
5353
<div
54-
{...mergeProps(tagRowProps, hoverProps, focusProps)}
54+
{...mergeProps(rowProps, hoverProps, focusProps)}
5555
className={classNames(
5656
styles,
5757
'spectrum-Tags-item',
@@ -66,7 +66,7 @@ export function Tag<T>(props: SpectrumTagProps<T>) {
6666
ref={ref}>
6767
<div
6868
className={classNames(styles, 'spectrum-Tag-cell')}
69-
{...tagProps}>
69+
{...gridCellProps}>
7070
<SlotProvider
7171
slots={{
7272
icon: {UNSAFE_className: classNames(styles, 'spectrum-Tag-icon'), size: 'XS'},

‎packages/@react-spectrum/tag/src/TagGroup.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
6262
), [direction, isCollapsed, state.collection, tagState.visibleTagCount]) as TagKeyboardDelegate<T>;
6363
// Remove onAction from props so it doesn't make it into useGridList.
6464
delete props.onAction;
65-
let {tagGroupProps, labelProps, descriptionProps, errorMessageProps} = useTagGroup({...props, keyboardDelegate}, state, tagsRef);
65+
let {gridProps, labelProps, descriptionProps, errorMessageProps} = useTagGroup({...props, keyboardDelegate}, state, tagsRef);
6666
let actionsId = useId();
6767

6868
let updateVisibleTagCount = useCallback(() => {
@@ -171,7 +171,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
171171
className={classNames(styles, 'spectrum-Tags-container')}>
172172
<div
173173
ref={tagsRef}
174-
{...tagGroupProps}
174+
{...gridProps}
175175
className={classNames(styles, 'spectrum-Tags')}>
176176
{visibleTags.map(item => (
177177
<Tag
@@ -191,7 +191,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
191191
role="group"
192192
id={actionsId}
193193
aria-label={stringFormatter.format('actions')}
194-
aria-labelledby={`${tagGroupProps.id} ${actionsId}`}
194+
aria-labelledby={`${gridProps.id} ${actionsId}`}
195195
className={classNames(styles, 'spectrum-Tags-actions')}>
196196
{tagState.showCollapseButton &&
197197
<ActionButton

0 commit comments

Comments
 (0)
Failed to load comments.