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

Components: Tab Panel: add initialTabIndex prop #6885

Merged
merged 1 commit into from Jun 27, 2018

Conversation

Projects
None yet
4 participants
@psealock
Contributor

psealock commented May 22, 2018

Description

This PR adds a prop initialTabIndex to the <TabPanel /> component for the purpose of designating a tab that is initially selected when the component mounts. The current behaviour is to default to the first tab

Use Case

I have a <TabPanel /> component that is hidden behind an expandable button. When the button is clicked and the view expands, I'd like the tab and subsequent selection to reflect the state of the app. Sometimes, that will be the second tab, "Custom" as seen below

screen shot 2018-05-22 at 4 46 40 pm

How has this been tested?

  • Applied the prop to <TabPanel /> instance
  • Created unit tests as part of this PR
  • The newly created prop initialTabIndex defaults to zero, so backwards compatibility is intact

Types of changes

New feature to <TabPanel />, adding a prop initialTabIndex to designate a tab that is initially selected when the component mounts

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
@jorgefilipecosta

Hi @psealock thank you for the PR 👍
Have you considered passing an initialTabName prop? onSelect and Function-as-Children component both reference the active tab using tabName. Maybe we should also use tabName to reference the initial tab.

@psealock

This comment has been minimized.

Contributor

psealock commented May 31, 2018

Thanks for the review @jorgefilipecosta . I agree, initialTabName makes more sense in this context. I updated the code to reflect that change.

Cheers

@psealock

This comment has been minimized.

Contributor

psealock commented Jun 13, 2018

Hi @jorgefilipecosta. Just wondering if you've had a chance to take a look at the updated code. Thanks!

Components: Tab Panel: add initialTabIndex prop
Use initialTabName instead of initialTabIndex
@psealock

This comment has been minimized.

Contributor

psealock commented Jun 27, 2018

Hi @gziolo I've updated README according to your suggestion. Cheers

@gziolo

gziolo approved these changes Jun 27, 2018

👍 thanks for wrangling it

@gziolo gziolo merged commit 7909eb2 into WordPress:master Jun 27, 2018

2 checks passed

codecov/project 46.77% (+<.01%) compared to e5e7335
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment