-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: EditableTable Cells from testing feedback #9108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Build successful! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
things look good to me for the most part, just one thing for Android that needs to be changed
| }; | ||
|
|
||
| // Can't differentiate between Dialog click outside dismissal and Escape key dismissal | ||
| let isMobile = !useMediaQuery('(any-pointer: fine)'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't seem to trigger for Android, might need to use touch: '@media not ((hover: hover) and (pointer: fine))', which is what the style macro uses
| useEffect(() => { | ||
| let dialog = dialogRef.current?.UNSAFE_getDOMNode(); | ||
| if (isOpen && dialog) { | ||
| let handler = (e: KeyboardEvent) => { | ||
| if (e.key === 'Escape') { | ||
| setIsOpen(false); | ||
| e.stopPropagation(); | ||
| e.preventDefault(); | ||
| } | ||
| }; | ||
| dialog.addEventListener('keydown', handler); | ||
| return () => { | ||
| dialog.removeEventListener('keydown', handler); | ||
| }; | ||
| } | ||
| }, [isOpen]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats a bit annoying that this needs to be done since dismissible dialogs close on touch start I assume... Feels like a relatively common use case too, wonder if we could support this by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Build successful! 🎉 |
|
Build successful! 🎉 |
## API Changes
@react-spectrum/s2/@react-spectrum/s2:EditableCell EditableCell {
+ action?: string | FormHTMLAttributes<HTMLFormElement>['action']
align?: 'start' | 'center' | 'end' = 'start'
children: ReactNode
colSpan?: number
id?: Key
isSaving?: boolean
- onSubmit: () => void
+ onCancel?: () => void
+ onSubmit?: (FormEvent<HTMLFormElement>) => void
renderEditing: () => ReactNode
showDivider?: boolean
textValue?: string
}@react-stately/data/@react-stately/data:ListData ListData <T> {
addKeysToSelection: (Selection) => void
append: (Array<T>) => void
filterText: string
getItem: (Key) => T | undefined
insert: (number, Array<T>) => void
insertAfter: (Key, Array<T>) => void
insertBefore: (Key, Array<T>) => void
items: Array<T>
move: (Key, number) => void
moveAfter: (Key, Iterable<Key>) => void
moveBefore: (Key, Iterable<Key>) => void
prepend: (Array<T>) => void
remove: (Array<Key>) => void
removeKeysFromSelection: (Selection) => void
removeSelectedItems: () => void
selectedKeys: Selection
setFilterText: (string) => void
setSelectedKeys: (Selection) => void
- update: (Key, T) => void
+ update: (Key, T | (T) => T) => void
}/@react-stately/data:AsyncListData AsyncListData <T> {
addKeysToSelection: (Selection) => void
append: (Array<T>) => void
error?: Error
filterText: string
getItem: (Key) => T | undefined
insert: (number, Array<T>) => void
insertAfter: (Key, Array<T>) => void
insertBefore: (Key, Array<T>) => void
isLoading: boolean
items: Array<T>
loadMore: () => void
loadingState: LoadingState
move: (Key, number) => void
moveAfter: (Key, Iterable<Key>) => void
moveBefore: (Key, Iterable<Key>) => void
prepend: (Array<T>) => void
reload: () => void
remove: (Array<Key>) => void
removeKeysFromSelection: (Selection) => void
removeSelectedItems: () => void
selectedKeys: Selection
setFilterText: (string) => void
setSelectedKeys: (Selection) => void
sort: (SortDescriptor) => void
sortDescriptor?: SortDescriptor
- update: (Key, T) => void
+ update: (Key, T | (T) => T) => void
} |
| * @param newValue - The new value for the item, or a function that returns the new value based on the previous value. | ||
| */ | ||
| update(key: Key, newValue: T): void | ||
| update(key: Key, newValue: T | ((prev: T) => T)): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works like useState's setState callback, we already had the previous value, so it was trivial to expose and it simplified my logic in my examples, no longer have to track the previous list state and depend on renders
Closes
This changes from the popover to a true dialog for touch devices where a keyboard may come into view and mess with the scroll position.
It removes the intermediate ref from the examples and uses the form submission to track updated values.
Adds aria labels and better label examples.
Removes inverted row hover color.
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: