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

chore: hide table rows while results are loading #6089

Closed

Conversation

jordanvn
Copy link
Member

@jordanvn jordanvn commented Nov 14, 2024

Description of changes

  • Conditionally set rows to an empty array while table data is not available

Issue #, if available

Description of how you validated changes

Checklist

  • Have read the Pull Request Guidelines
  • PR description included
  • yarn test passes and tests are updated/added
  • PR title and commit messages follow conventional commit syntax
  • If this change should result in a version bump, changeset added (This can be done after creating the PR.) This does not apply to changes made to docs, e2e, examples, or other private packages.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

changeset-bot bot commented Nov 14, 2024

⚠️ No Changeset found

Latest commit: 95fcac5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines -52 to -89
const mappedRows = rows.map(({ key, content }) => ({
key,
content: content.map(({ key, content, type }) => {
switch (type) {
case 'button': {
return {
key,
content: <ButtonDataCell content={content} />,
};
}
case 'checkbox': {
return {
key,
content: <CheckboxDataCell content={content} />,
};
}
case 'date': {
return {
key,
content: <DateDataCell content={content} />,
};
}
case 'number': {
return {
key,
content: <NumberDataCell content={content} />,
};
}
case 'text':
default: {
return {
key,
content: <TextDataCell content={content} />,
};
}
}
}),
}));
Copy link
Member Author

Choose a reason for hiding this comment

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

There is no change to this section, it is just wrapped in conditional logic

@jordanvn jordanvn marked this pull request as ready for review November 15, 2024 16:24
@jordanvn jordanvn requested a review from a team as a code owner November 15, 2024 16:24
@jordanvn jordanvn marked this pull request as draft November 15, 2024 16:25
dbanksdesign
dbanksdesign previously approved these changes Nov 15, 2024
className={`${STORAGE_BROWSER_BLOCK}__loading-indicator-text`}
aria-live="polite"
>
Loading
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be provided as a prop so it can handled by display text

Copy link
Member Author

@jordanvn jordanvn Nov 15, 2024

Choose a reason for hiding this comment

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

Updated to be provided as a prop, passing in existing DEFAULT_LIST_VIEW_DISPLAY_TEXT.loadingIndicatorLabel

return (
<ViewElement className={`${STORAGE_BROWSER_BLOCK}__table-wrapper`}>
<Table headers={mappedHeaders} rows={mappedRows} />
{!!isLoading && <LoadingIndicator />}
Copy link
Member

Choose a reason for hiding this comment

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

Prefer not to return false in JSX statements

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to return null instead

}),
}));
const mappedRows = !isLoading
? rows.map(({ key, content }) => ({
Copy link
Member

Choose a reason for hiding this comment

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

Prefer early return of empty array for readability

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. Updated

Copy link
Member

@AllanZhengYP AllanZhengYP left a comment

Choose a reason for hiding this comment

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

Looks good to me

AllanZhengYP
AllanZhengYP previously approved these changes Nov 17, 2024
Copy link
Member

@AllanZhengYP AllanZhengYP left a comment

Choose a reason for hiding this comment

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

Looks good to me

@jordanvn jordanvn changed the title chore: move loading indicator into table, hide table contents while loading chore: hide table rows while results are loading Nov 19, 2024
@jordanvn
Copy link
Member Author

Moving to #6183

@jordanvn jordanvn closed this Nov 20, 2024
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.

5 participants