Skip to content

Commit 4efd535

Browse files
committed
fix extra or missing props
1 parent b2b29fb commit 4efd535

File tree

6 files changed

+53
-14
lines changed

6 files changed

+53
-14
lines changed

packages/@react-aria/gridlist/src/useGridListItem.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ export function useGridListItem<T>(props: AriaGridListItemOptions, state: ListSt
283283
onKeyDown,
284284
onFocus,
285285
// 'aria-label': [(node.textValue || undefined), rowAnnouncement].filter(Boolean).join(', '),
286-
'aria-label': node.textValue || undefined,
286+
'aria-label': node['aria-label'] || node.textValue || undefined,
287287
'aria-selected': state.selectionManager.canSelectItem(node.key) ? state.selectionManager.isSelected(node.key) : undefined,
288288
'aria-disabled': state.selectionManager.isDisabled(node.key) || undefined,
289-
'aria-labelledby': descriptionId && node.textValue ? `${getRowId(state, node.key)} ${descriptionId}` : undefined,
289+
'aria-labelledby': descriptionId && (node['aria-label'] || node.textValue) ? `${getRowId(state, node.key)} ${descriptionId}` : undefined,
290290
id: getRowId(state, node.key)
291291
});
292292

packages/@react-spectrum/s2/src/TableView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import Chevron from '../ui-icons/Chevron';
5858
import Close from '../s2wf-icons/S2_Icon_Close_20_N.svg';
5959
import {ColumnSize} from '@react-types/table';
6060
import {CustomDialog, DialogContainer} from '..';
61-
import {DOMRef, DOMRefValue, forwardRefType, GlobalDOMAttributes, LoadingState, Node} from '@react-types/shared';
61+
import {DOMProps, DOMRef, DOMRefValue, forwardRefType, GlobalDOMAttributes, LoadingState, Node} from '@react-types/shared';
6262
import {getActiveElement, getOwnerDocument, useLayoutEffect, useObjectRef} from '@react-aria/utils';
6363
import {GridNode} from '@react-types/grid';
6464
import {IconContext} from './Icon';
@@ -120,7 +120,7 @@ interface S2TableProps {
120120
}
121121

122122
// TODO: Note that loadMore and loadingState are now on the Table instead of on the TableBody
123-
export interface TableViewProps extends Omit<RACTableProps, 'style' | 'disabledBehavior' | 'className' | 'onRowAction' | 'selectionBehavior' | 'onScroll' | 'onCellAction' | 'dragAndDropHooks' | keyof GlobalDOMAttributes>, UnsafeStyles, S2TableProps {
123+
export interface TableViewProps extends Omit<RACTableProps, 'style' | 'className' | 'onRowAction' | 'selectionBehavior' | 'onScroll' | 'onCellAction' | 'dragAndDropHooks' | keyof GlobalDOMAttributes>, DOMProps, UnsafeStyles, S2TableProps {
124124
/** Spectrum-defined styles, returned by the `style()` macro. */
125125
styles?: StylesPropWithHeight
126126
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {ClearButton} from './ClearButton';
3535
import {Collection, CollectionBuilder} from '@react-aria/collections';
3636
import {control, field, getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};
3737
import {createContext, forwardRef, ReactNode, useContext, useEffect, useMemo, useRef, useState} from 'react';
38-
import {DOMRef, DOMRefValue, GlobalDOMAttributes, HelpTextProps, Node, SpectrumLabelableProps} from '@react-types/shared';
38+
import {DOMRef, DOMRefValue, GlobalDOMAttributes, HelpTextProps, LabelableProps, Node, SpectrumLabelableProps} from '@react-types/shared';
3939
import {FieldLabel, helpTextStyles} from './Field';
4040
import {flushSync} from 'react-dom';
4141
import {FormContext, useFormProps} from './Form';
@@ -52,7 +52,7 @@ import {useLocalizedStringFormatter} from '@react-aria/i18n';
5252
import {useSpectrumContextProps} from './useSpectrumContextProps';
5353

5454
// Get types from RSP and extend those?
55-
export interface TagProps extends Omit<AriaTagProps, 'children' | 'style' | 'className' | 'onClick' | keyof GlobalDOMAttributes> {
55+
export interface TagProps extends Omit<AriaTagProps, 'children' | 'style' | 'className' | 'onClick' | keyof GlobalDOMAttributes>, LabelableProps {
5656
/** The children of the tag. */
5757
children: ReactNode
5858
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2022 Adobe. All rights reserved.
3+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License. You may obtain a copy
5+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under
8+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
* OF ANY KIND, either express or implied. See the License for the specific language
10+
* governing permissions and limitations under the License.
11+
*/
12+
13+
import React from 'react';
14+
import {render} from '@react-spectrum/test-utils-internal';
15+
import {Tag, TagGroup} from '../';
16+
17+
let TestTagGroup = ({tagGroupProps, itemProps}) => (
18+
<TagGroup data-testid="group" {...tagGroupProps}>
19+
<Tag {...itemProps} id="cat">Cat</Tag>
20+
<Tag {...itemProps} id="dog">Dog</Tag>
21+
<Tag {...itemProps} id="kangaroo">Kangaroo</Tag>
22+
</TagGroup>
23+
);
24+
25+
let renderTagGroup = (tagGroupProps = {}, itemProps = {}) => render(<TestTagGroup {...{tagGroupProps, itemProps}} />);
26+
27+
describe('TagGroup', () => {
28+
beforeAll(() => {
29+
jest.useFakeTimers();
30+
});
31+
32+
it('should aria label on tags', () => {
33+
let {getAllByRole} = renderTagGroup({label: 'TagGroup label'}, {'aria-label': 'Test'});
34+
35+
for (let row of getAllByRole('row')) {
36+
expect(row).toHaveAttribute('aria-label', 'Test');
37+
}
38+
});
39+
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface AriaTabPanelProps extends Omit<DOMProps, 'id'>, AriaLabelingPro
6060
id?: Key
6161
}
6262

63-
export interface SpectrumTabsProps<T> extends AriaTabListBase, Omit<SingleSelection, 'onSelectionChange'>, DOMProps, StyleProps {
63+
export interface SpectrumTabsProps<T> extends AriaTabListBase, Omit<SingleSelection, 'onSelectionChange' | 'disallowEmptySelection'>, DOMProps, StyleProps {
6464
/** The children of the `<Tabs>` element. Should include `<TabList>` and `<TabPanels>` elements. */
6565
children: ReactNode,
6666
/** The item objects for each tab, for dynamic collections. */

packages/react-aria-components/test/TagGroup.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,9 @@ describe('TagGroup', () => {
527527
let {getAllByRole} = renderTagGroup({selectionMode: 'single', onSelectionChange});
528528
let items = getAllByRole('row');
529529

530-
await user.pointer({target: items[0], keys: '[MouseLeft>]'});
530+
await user.pointer({target: items[0], keys: '[MouseLeft>]'});
531531
expect(onSelectionChange).toBeCalledTimes(1);
532-
532+
533533
await user.pointer({target: items[0], keys: '[/MouseLeft]'});
534534
expect(onSelectionChange).toBeCalledTimes(1);
535535
});
@@ -539,9 +539,9 @@ describe('TagGroup', () => {
539539
let {getAllByRole} = renderTagGroup({selectionMode: 'single', onSelectionChange, shouldSelectOnPressUp: false});
540540
let items = getAllByRole('row');
541541

542-
await user.pointer({target: items[0], keys: '[MouseLeft>]'});
542+
await user.pointer({target: items[0], keys: '[MouseLeft>]'});
543543
expect(onSelectionChange).toBeCalledTimes(1);
544-
544+
545545
await user.pointer({target: items[0], keys: '[/MouseLeft]'});
546546
expect(onSelectionChange).toBeCalledTimes(1);
547547
});
@@ -551,9 +551,9 @@ describe('TagGroup', () => {
551551
let {getAllByRole} = renderTagGroup({selectionMode: 'single', onSelectionChange, shouldSelectOnPressUp: true});
552552
let items = getAllByRole('row');
553553

554-
await user.pointer({target: items[0], keys: '[MouseLeft>]'});
554+
await user.pointer({target: items[0], keys: '[MouseLeft>]'});
555555
expect(onSelectionChange).toBeCalledTimes(0);
556-
556+
557557
await user.pointer({target: items[0], keys: '[/MouseLeft]'});
558558
expect(onSelectionChange).toBeCalledTimes(1);
559559
});
@@ -572,7 +572,7 @@ describe('TagGroup', () => {
572572
let {getByRole} = renderTagGroup({selectionMode: 'multiple'}, {}, {onPressStart, onPressEnd, onPress, onClick});
573573
let tester = testUtilUser.createTester('GridList', {root: getByRole('grid')});
574574
await tester.triggerRowAction({row: 1, interactionType});
575-
575+
576576
expect(onPressStart).toHaveBeenCalledTimes(1);
577577
expect(onPressEnd).toHaveBeenCalledTimes(1);
578578
expect(onPress).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)