Skip to content

Commit 72ee92f

Browse files
authored
Adding descriptions to Tag related interfaces (#4053)
* Adding descriptions to Tag related interfaces * Add description for ref
1 parent 6013307 commit 72ee92f

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,21 @@ import {useLocalizedStringFormatter} from '@react-aria/i18n';
2323

2424

2525
export interface TagAria {
26+
/** Props for the tag visible label (if any). */
2627
labelProps: DOMAttributes,
28+
/** Props for the tag cell element. */
2729
tagProps: DOMAttributes,
30+
/** Props for the tag row element. */
2831
tagRowProps: DOMAttributes,
32+
/** Props for the tag clear button. */
2933
clearButtonProps: AriaButtonProps
3034
}
3135

3236
/**
3337
* Provides the behavior and accessibility implementation for a tag component.
3438
* @param props - Props to be applied to the tag.
3539
* @param state - State for the tag group, as returned by `useTagGroupState`.
40+
* @param ref - A ref to a DOM element for the tag.
3641
*/
3742
export function useTag<T>(props: TagProps<T>, state: TagGroupState<T>, ref: RefObject<FocusableElement>): TagAria {
3843
let {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import {ActionButton} from '@react-spectrum/button';
1414
import {AriaTagGroupProps, TagKeyboardDelegate, useTagGroup} from '@react-aria/tag';
1515
import {classNames, useDOMRef} from '@react-spectrum/utils';
16-
import {DOMRef, SpectrumHelpTextProps, SpectrumLabelableProps, StyleProps, Validation} from '@react-types/shared';
16+
import {DOMRef, SpectrumHelpTextProps, SpectrumLabelableProps, StyleProps} from '@react-types/shared';
1717
import {Field} from '@react-spectrum/label';
1818
import {FocusScope} from '@react-aria/focus';
1919
// @ts-ignore
@@ -28,7 +28,7 @@ import {useId, useLayoutEffect, useResizeObserver, useValueEffect} from '@react-
2828
import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
2929
import {useTagGroupState} from '@react-stately/tag';
3030

31-
export interface SpectrumTagGroupProps<T> extends AriaTagGroupProps<T>, StyleProps, SpectrumLabelableProps, Validation, Omit<SpectrumHelpTextProps, 'showErrorIcon'> {
31+
export interface SpectrumTagGroupProps<T> extends AriaTagGroupProps<T>, StyleProps, SpectrumLabelableProps, Omit<SpectrumHelpTextProps, 'showErrorIcon'> {
3232
/** The label to display on the action button. */
3333
actionLabel?: string,
3434
/** Handler that is called when the action button is pressed. */
@@ -70,7 +70,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
7070
let computeVisibleTagCount = () => {
7171
// Refs can be null at runtime.
7272
let currDomRef: HTMLDivElement | null = domRef.current;
73-
let currContainerRef: HTMLDivElement | null = containerRef.current;
73+
let currContainerRef: HTMLDivElement | null = containerRef.current;
7474
let currTagsRef: HTMLDivElement | null = tagsRef.current;
7575
if (!currDomRef || !currContainerRef || !currTagsRef) {
7676
return;
@@ -113,7 +113,7 @@ function TagGroup<T extends object>(props: SpectrumTagGroupProps<T>, ref: DOMRef
113113
}
114114
return {visibleTagCount: index, showCollapseButton: index < state.collection.size};
115115
};
116-
116+
117117
setTagState(function *() {
118118
// Update to show all items.
119119
yield {visibleTagCount: state.collection.size, showCollapseButton: true};

packages/@react-types/tag/src/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ export interface TagGroupProps<T> extends Omit<CollectionBase<T>, 'disabledKeys'
2323
}
2424

2525
export interface TagProps<T> extends ItemProps<any> {
26+
/** Whether the tag is focused. */
2627
isFocused: boolean,
28+
/** Whether the tag is removable. */
2729
allowsRemoving?: boolean,
30+
/** An object representing the tag. Contains all the relevant information that makes up the tag. */
2831
item: Node<T>,
32+
/** Handler that is called when the user triggers the tag's remove button. */
2933
onRemove?: (key: Key) => void
3034
}

0 commit comments

Comments
 (0)