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 hook that returns disabled value in RowContext #11759

Closed
wants to merge 3 commits into from

Conversation

gwyneplaine
Copy link
Contributor

@gwyneplaine gwyneplaine commented Mar 19, 2024

WHY are these changes introduced?

We don't yet expose the disabled value for children of the RowContext.Provider to consume.
This is something we discovered we need in the following web PR
See problem outlined in the following comment.

We already expose the hover and selected context values via the useRowHovered and useRowSelected hooks respectively. This aligns with that convention.

WHAT is this pull request doing?

Following convention established in the useRowHovered and useRowSelected hooks to return as small a slice of state as possible, we expose a useRowDisabled hook so that context children can access the disabled state of the parent Row. (Needed for https://github.com/Shopify/web/pull/121521)

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

🎩 checklist

@gwyneplaine gwyneplaine marked this pull request as ready for review March 19, 2024 04:30
@yurm04 yurm04 requested a review from a team March 19, 2024 15:39
.changeset/lucky-seahorses-invent.md Outdated Show resolved Hide resolved
Copy link
Member

@sam-b-rose sam-b-rose left a comment

Choose a reason for hiding this comment

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

This looks good to me! Though, would it be better to have a single hook for getting RowContext data, then adding more context data as needed?

const {disabled, hovered, selected, ...etc } = useIndexTableRow()

Then we could clean up the single-property hooks like useRowHovered and useRowSelected.

@gwyneplaine
Copy link
Contributor Author

This looks good to me! Though, would it be better to have a single hook for getting RowContext data, then adding more context data as needed?

const {disabled, hovered, selected, ...etc } = useIndexTableRow()

Then we could clean up the single-property hooks like useRowHovered and useRowSelected.

Absolutely down to combine all consumption of RowContext into one useIndexTableRow hook. Caveat being that the hover value needs to be separate, and in fact currently belongs to a separate context RowHoverContext.

The choice to keep that in its own context provider was to reduce the potential performance hit of leaf nodes rerendering due to hover state changing in context, when other context values that are less frequently updated are being used. (Since context updates only re-renders for children that use that context, not all children of the context provider)

Happy to combine selected and disabled in a subsequent PR 👍

@aaronccasanova aaronccasanova force-pushed the clee/add-row-disabled-context-hook branch from 0c3af34 to f2c62d0 Compare April 19, 2024 21:52
@github-actions github-actions bot added the cla-needed Added by a bot. Contributor needs to sign the CLA Agreement. label Apr 19, 2024
@translation-platform
Copy link
Contributor

Localization quality issues found

The following issues may affect the quality of localized translations if they are not addressed:

  • The value Clear for key Polaris.ActionList.SearchField.clearButtonLabel is very short. Short strings are more likely to be misunderstood by translators without context. Please provide additional context for the translators if possible.
  • The value Search for key Polaris.ActionList.SearchField.search is very short. Short strings are more likely to be misunderstood by translators without context. Please provide additional context for the translators if possible.
  • The value Search actions for key Polaris.ActionList.SearchField.placeholder is very short. Short strings are more likely to be misunderstood by translators without context. Please provide additional context for the translators if possible.

Please look out for other instances of this issue in your PR and fix them as well if possible.

Questions about these messages? Hop in the #help-localization Slack channel.

Copy link
Contributor

Hi! We noticed there hasn’t been activity on this PR in a while. After 30 days, it will close automatically.

If it’s still relevant, or you have updates, comment and let us know. And don’t worry, you can always re-open later if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-needed Added by a bot. Contributor needs to sign the CLA Agreement. no-pr-activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants