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

fix(theme): <Tabs> props should allow overriding defaults #10091

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

gagdiez
Copy link
Contributor

@gagdiez gagdiez commented Apr 30, 2024

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

By switching the priority of inner properties (...tabs) with input properties (...props), we allow the users to control the selectedValue (i.e. switch tabs), as well as to pass a hook selectValue to act on a tab switch.

This is a minor change that should improve UX while not changing anything else.

Test Plan

Existing tests should suffice, since no major change was introduced, only the place of the variables was swapped to give higher priority to the input props

Test links

https://deploy-preview-10091--docusaurus-2.netlify.app/docs/markdown-features/tabs/

Related issues/PRs

Related to this feature request: https://docusaurus.io/feature-requests/p/pass-active-attribute-to-tab-children

By switching the priority of inner properties (`...tabs`) with input properties (`...props`), we allow the users to control the `selectedValue` (i.e. switch tabs), as well as to pass a hook `selectValue` to act on a tab switch.

This is a minor change that should improve UX while not changing anything else.
@facebook-github-bot
Copy link
Contributor

Hi @gagdiez!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Copy link

netlify bot commented Apr 30, 2024

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 2ed4cb1
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6630e7f65d28640008f5d851
😎 Deploy Preview https://deploy-preview-10091--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 51 🟢 98 🟢 96 🟢 100 🟠 88 Report
/docs/installation 🟠 60 🟢 96 🟢 100 🟢 100 🟠 88 Report
/docs/category/getting-started 🟠 76 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog 🟠 70 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 63 🟢 96 🟢 100 🟢 100 🟠 88 Report
/blog/tags/release 🟠 69 🟢 100 🟢 100 🟠 80 🟠 88 Report
/blog/tags 🟠 77 🟢 100 🟢 100 🟢 90 🟠 88 Report

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Apr 30, 2024
@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Apr 30, 2024
@slorber slorber changed the title feat: Give priority to input props on Tabs fix(theme): <Tabs> props should allow overriding defaults Apr 30, 2024
@slorber
Copy link
Collaborator

slorber commented Apr 30, 2024

Thanks

Ok to do this change, although I'm not sure I'd want to recommend this pattern considering you can mess up with internals.

Note that we won't expose the 3 things you can now override in the TS typedefs, to prevent most users from using those props.

I'm really curious to know how you plan to use those props. Are you also using our internal useTabs() hook in your code? Maybe it would be better to expose a controlled variant of the underlying component instead?

@slorber slorber merged commit 2154dcc into facebook:main Apr 30, 2024
33 checks passed
@slorber
Copy link
Collaborator

slorber commented Apr 30, 2024

😄 I see

Maybe it would be simpler to use your own tab component instead, we provide one for convenience but you can also create your own if it's not good enough for your advanced use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants