Skip to content

Commit 4357081

Browse files
authored
Fix Picker and ComboBox press state, Table types + docs (#7086)
* Fix ComboBox and Picker getting stuck in down state * Fix table types and export from package
1 parent 9686085 commit 4357081

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ function ComboBox<T extends object>(props: ComboBoxProps<T>, ref: Ref<TextFieldR
263263
{isInvalid && <FieldErrorIcon isDisabled={isDisabled} />}
264264
<Button
265265
ref={buttonRef}
266+
// Prevent press scale from sticking while ComboBox is open.
267+
// @ts-ignore
268+
isPressed={false}
266269
style={renderProps => pressScale(buttonRef)(renderProps)}
267270
className={renderProps => inputButton({
268271
...renderProps,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ function Picker<T extends object>(props: PickerProps<T>, ref: FocusableRef<HTMLB
285285
<Button
286286
ref={domRef}
287287
style={renderProps => pressScale(domRef)(renderProps)}
288+
// Prevent press scale from sticking while Picker is open.
289+
// @ts-ignore
290+
isPressed={false}
288291
className={renderProps => inputButton({
289292
...renderProps,
290293
size: size,

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ import {
2929
TableBody as RACTableBody,
3030
TableBodyProps as RACTableBodyProps,
3131
TableHeader as RACTableHeader,
32+
TableHeaderProps as RACTableHeaderProps,
3233
TableProps as RACTableProps,
3334
ResizableTableContainer,
3435
RowRenderProps,
3536
TableBodyRenderProps,
36-
TableHeaderProps,
3737
TableRenderProps,
3838
UNSTABLE_TableLayout,
3939
UNSTABLE_TableLoadingIndicator,
@@ -45,7 +45,7 @@ import {centerPadding, getAllowedOverrides, StylesPropWithHeight, UnsafeStyles}
4545
import {Checkbox} from './Checkbox';
4646
import Chevron from '../ui-icons/Chevron';
4747
import {ColumnSize} from '@react-types/table';
48-
import {DOMRef, forwardRefType, LoadingState, Node} from '@react-types/shared';
48+
import {DOMRef, LoadingState, Node} from '@react-types/shared';
4949
import {fontRelative, lightDark, size, style} from '../style/spectrum-theme' with {type: 'macro'};
5050
import {GridNode} from '@react-types/grid';
5151
import {IconContext} from './Icon';
@@ -814,6 +814,8 @@ const selectAllCheckboxColumn = style({
814814

815815
let InternalTableHeaderContext = createContext<{isHeaderRowHovered?: boolean}>({isHeaderRowHovered: false});
816816

817+
export interface TableHeaderProps<T> extends Omit<RACTableHeaderProps<T>, 'style' | 'className' | 'dependencies'> {}
818+
817819
/**
818820
* A header within a `<Table>`, containing the table columns.
819821
*/
@@ -1125,5 +1127,5 @@ export function Row<T extends object>({id, columns, children, ...otherProps}: Ro
11251127
/**
11261128
* Tables are containers for displaying information. They allow users to quickly scan, sort, compare, and take action on large amounts of data.
11271129
*/
1128-
const _Table = /*#__PURE__*/ (forwardRef as forwardRefType)(Table);
1130+
const _Table = forwardRef(Table);
11291131
export {_Table as Table};

packages/@react-spectrum/s2/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export {Skeleton, useIsSkeleton} from './Skeleton';
6363
export {SkeletonCollection} from './SkeletonCollection';
6464
export {StatusLight, StatusLightContext} from './StatusLight';
6565
export {Switch, SwitchContext} from './Switch';
66+
export {Table, TableHeader, TableBody, Row, Cell, Column} from './Table';
6667
export {Tabs, TabList, Tab, TabPanel, TabsContext} from './Tabs';
6768
export {TagGroup, Tag, TagGroupContext} from './TagGroup';
6869
export {TextArea, TextField, TextAreaContext, TextFieldContext} from './TextField';
@@ -121,6 +122,7 @@ export type {SkeletonProps} from './Skeleton';
121122
export type {SkeletonCollectionProps} from './SkeletonCollection';
122123
export type {StatusLightProps} from './StatusLight';
123124
export type {SwitchProps} from './Switch';
125+
export type {TableProps, TableHeaderProps, TableBodyProps, RowProps, CellProps, ColumnProps} from './Table';
124126
export type {TabsProps, TabProps, TabListProps, TabPanelProps} from './Tabs';
125127
export type {TagGroupProps, TagProps} from './TagGroup';
126128
export type {TextFieldProps, TextAreaProps} from './TextField';

packages/@react-spectrum/s2/stories/Table.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
*/
1212

1313
import {action} from '@storybook/addon-actions';
14-
import {ActionButton, Content, Heading, IllustratedMessage, Link} from '../src';
14+
import {ActionButton, Cell, Column, Content, Heading, IllustratedMessage, Link, Row, Table, TableBody, TableHeader} from '../src';
1515
import {categorizeArgTypes} from './utils';
16-
import {Cell, Column, Row, Table, TableBody, TableHeader} from '../src/Table';
1716
import FolderOpen from '../spectrum-illustrations/linear/FolderOpen';
1817
import type {Meta} from '@storybook/react';
1918
import {SortDescriptor} from 'react-aria-components';

0 commit comments

Comments
 (0)