Skip to content
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

Add isRootDropTarget parameter to renderEmptyState in GridList component #5211

Merged

Conversation

gennadiipel
Copy link
Contributor

@gennadiipel gennadiipel commented Oct 6, 2023

Add isRootDropTarget parameter to renderEmptyState in GridList component

Closes #5210

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

Copy link
Member

@reidbarber reidbarber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea a lot!

I say we go ahead and pass all the render props in (except for isEmpty since it is implied). And we can use one argument with everything.

@@ -176,7 +176,7 @@ function GridListInner<T extends object>({props, collection, gridListRef: ref}:
// they don't affect the layout of the children. However, WebKit currently has
// a bug that makes grid elements with display: contents hidden to screen readers.
// https://bugs.webkit.org/show_bug.cgi?id=239479
let content = props.renderEmptyState();
let content = props.renderEmptyState(isRootDropTarget);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let content = props.renderEmptyState(isRootDropTarget);
let content = props.renderEmptyState({
isDropTarget: isRootDropTarget,
isFocused,
isFocusVisible,
state
});

@@ -54,7 +54,7 @@ export interface GridListProps<T> extends Omit<AriaGridListProps<T>, 'children'>
/** The drag and drop hooks returned by `useDragAndDrop` used to enable drag and drop behavior for the GridList. */
dragAndDropHooks?: DragAndDropHooks,
/** Provides content to display when there are no items in the list. */
renderEmptyState?: () => ReactNode
renderEmptyState?: (isRootDropTarget: boolean) => ReactNode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
renderEmptyState?: (isRootDropTarget: boolean) => ReactNode
renderEmptyState?: (props: {isDropTarget: boolean, isFocused: boolean, isFocusVisible: boolean, state: ListState<unknown>}) => ReactNode

@gennadiipel gennadiipel force-pushed the add-is-root-drop-target-to-gridlist branch from 2231b33 to 0c48238 Compare October 6, 2023 16:00
@reidbarber
Copy link
Member

GET_BUILD

@rspbot
Copy link

rspbot commented Oct 6, 2023

reidbarber
reidbarber previously approved these changes Oct 6, 2023
@@ -176,7 +176,12 @@ function GridListInner<T extends object>({props, collection, gridListRef: ref}:
// they don't affect the layout of the children. However, WebKit currently has
// a bug that makes grid elements with display: contents hidden to screen readers.
// https://bugs.webkit.org/show_bug.cgi?id=239479
let content = props.renderEmptyState();
let content = props.renderEmptyState({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like a fine approach to me
we will need this in ListBox, Table, and TagGroup as well in order to be consistent
also, some form of a test/storybook example would be appreciated if you do not mind https://react-spectrum.adobe.com/contribute.html#pull-requests

@gennadiipel
Copy link
Contributor Author

@snowystinger @reidbarber Hello, I updated Table, ListBox and TagGroup. Also updated docs a little and added example of reorderable tables including PR's changes to storybook. Please take a look.

@snowystinger
Copy link
Member

GET_BUILD

@rspbot
Copy link

rspbot commented Oct 9, 2023

@@ -850,7 +850,7 @@ Use the `renderEmptyState` prop to customize what the `ListBox` will display if
<ListBox
aria-label="Search results"
/*- begin highlight -*/
renderEmptyState={() => 'No results found.'}
renderEmptyState={({isDropTarget, state, isFocused, isFocusVisible}) => <span style={{color: isDropTarget ? 'red' : 'black'}}>No results found.</span>}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are great, though in dark mode, it's a little hard to see
Screenshot 2023-10-10 at 1 59 16 PM

Instead, we should use one of the variables available to us in our docs, --spectrum-alias-text-color
There is another issue, though: I cannot drop anything on this example, so it never goes to red.

As a result, I think it should be in the example a little further down https://github.com/adobe/react-spectrum/blob/main/packages/react-aria-components/docs/ListBox.mdx#L1101
And instead of changing colors (esp to red which is negative), let's swap the string. Something like

isDropTarget ? 'This will not be uploaded' : 'Drop items here'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, updated docs like that in all of the cases and also added for GridList (forgot this one)

@gennadiipel gennadiipel force-pushed the add-is-root-drop-target-to-gridlist branch from ccd1870 to 1f1576c Compare October 10, 2023 08:32
@reidbarber
Copy link
Member

GET_BUILD

@rspbot
Copy link

rspbot commented Oct 10, 2023

@rspbot
Copy link

rspbot commented Oct 10, 2023

## API Changes

unknown top level export { type: 'identifier', name: 'Column' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }

reidbarber
reidbarber previously approved these changes Oct 10, 2023
Copy link
Member

@reidbarber reidbarber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!!

snowystinger
snowystinger previously approved these changes Oct 10, 2023
@snowystinger snowystinger dismissed stale reviews from reidbarber and themself via 51c0be2 October 10, 2023 21:51
@snowystinger snowystinger merged commit 778eaa4 into adobe:main Oct 11, 2023
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add isRootDropTarget parameter to renderEmptyState in GridList component
5 participants