Skip to content

Tabs #1

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

Closed
wants to merge 3 commits into from
Closed

Tabs #1

wants to merge 3 commits into from

Conversation

Apatil15
Copy link
Contributor

Please add your suggestions for the RFC Technical design document

@sh0ji sh0ji requested review from sh0ji and removed request for sh0ji October 21, 2021 20:12
Copy link
Contributor

@sh0ji sh0ji left a comment

Choose a reason for hiding this comment

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

Summarized comment


#### Tabs

The component or element the *Tabs* should render as *Fragment*.
Copy link

@dmedjordan dmedjordan Oct 22, 2021

Choose a reason for hiding this comment

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

The version on SharePoint has Tabs rendered as 'div'. Evan presented rational for both. Just wanted to make sure 'Fragment' is where the final decision landed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tabs is just a wrapper on tab list and tab panel, without any events, In case add any events or pros it would be carry forward to the child element like tab list.

##### Properties

| Props | Type | Default | Required | Description |

Choose a reason for hiding this comment

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

Evan had a comment about the Required field in the SharePoint version. You responded but I am not clear on what the end result is supposed to be.

Copy link
Contributor

Choose a reason for hiding this comment

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

The result should be that all rows need either true or false in the required column. The design should be as unambiguous as possible, so let's not leave anything up to inference like "empty means false."

Choose a reason for hiding this comment

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

Based on Evan's comment from Friday, each cell in the Required column (in each section) needs to have a value of Yes (True) or No (False)

##### Properties

| Props | Type | Default | Required | Description |
| :------------- |:-------------:|:-------------:|:-------------:|:-------------|
| ClassName| Object | | | Override or extend component style.|

Choose a reason for hiding this comment

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

The below are observations...not necessarily anything wrong

  • Name and Description for line #48 is different from SharePoint version
  • Line #50 is not in the SharePoint version
  • Is the Description for line #52 supposed to be the same as the Description for line #51?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Not sure if my last question was answered. Are the Descriptions for SelectedIndex (line #51) and onSelected (line #52) supposed to be the same?

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, the onSelected props should be something like, "A callback function that is triggered when a tab is selected."

##### Properties

| Props | Type | Default | Required | Description |
| :------------- |:-------------:|:-------------:|:-------------:|:-------------|
| Active| Boolean | | | Selected, Unselected flag, based on this flag active tab.|

Choose a reason for hiding this comment

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

More observations...not necessarily anything wrong

  • In the SharePoint version, the Name for line #63 is Selected
  • In the SharePoint version, the Description for line # 64 does NOT have the '<![endif]-->'
  • In the SharePoint version, there is a Name / Description for Label

Choose a reason for hiding this comment

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

@Apatil15 , were any of these bullets addressed?

Choose a reason for hiding this comment

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

The Specification document lists the States as:

  • Selected
  • Unselected
  • Disabled

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, Active should be selected and its description should probably call out that it sets aria-selected on the tab. The current description is a bit confusing. Maybe, "When set, indicates that the tab is currently selected and its corresponding TabPanel is visible. Sets the aria-selected attribute."

##### Properties

| Props | Type | Default | Required | Description |
| :------------- |:-------------:|:-------------:|:-------------:|:-------------|
| ClassName| Object | | | Override or extend component style.|
| Id | String | | | Unique identification of tabs. |

Choose a reason for hiding this comment

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

In the SharePoint version, the Description references 'tabpanel'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right it should be tabpanel.

##### Properties

| Props | Type | Default | Required | Description |
| :------------- |:-------------:|:-------------:|:-------------:|:-------------|
| ClassName| Object | | | Override or extend component style.|
| Id | String | | | Unique identification of tabs. |
| Children | Node | | | Override or extend component style. |

Choose a reason for hiding this comment

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

In the SharePoint version, the Description reads "Any component or element"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


<img width="578" alt="image" src="https://user-images.githubusercontent.com/25932161/137789481-c6078525-413c-47b8-b520-498934b99f6b.png">

Choose a reason for hiding this comment

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

Noted the following in the Design Flow diagrams:

  • <> Tabs: SharePoint version had an onSelected item
  • <> TabList: SharePoint version did not have an onSelected item
  • <> Tab: Should the Icon and IconRight items be listed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, It should not be there, I changed it

Choose a reason for hiding this comment

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

In the Interface-Tab design flow:

  • Should Index be labeled as defaultIndex?
  • Should ClassName be listed?

- nds—tabs (base)
- nds-tabs__tablist
- nds-tabs__tabpanel
- nds—tabs__tab

Choose a reason for hiding this comment

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

The SharePoint version did not have nds-tabs_tab listed

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like it's in response to my point about following BEM conventions to encode the anatomy.

  • "tabs" is the block name
  • tablist, tab, and tabpanel are the elements
    • this leads to the awkward nds-tabs__tab
  • an example of a modifier might be something like nds-tabs--vertical if we wanted a different display for a vertical orientation (using aria-orientation as a selector would probably be more semantic, though).

|Space or Enter | Activate tab if tabs are not activated.
|Home | Focus move to first tab.
|End | Focus moves to last tab.
| ArrowLeft| Move focus to previous column. |

Choose a reason for hiding this comment

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

The SharePoint version states "previous tab" instead of "previous column"
NOTE: If the tab is vertical, should we list ArrowUp to move focus to the previous tab?

Choose a reason for hiding this comment

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

I didn't see any mention of ArrowUp or ArrowDown.

|Home | Focus move to first tab.
|End | Focus moves to last tab.
| ArrowLeft| Move focus to previous column. |
| ArrowRight| Move focus to next column. |

Choose a reason for hiding this comment

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

The SharePoint version states "next tab" instead of "next column"
NOTE: If the tab is vertical, should we list ArrowDown to move focus to the next tab?

Copy link
Contributor

Choose a reason for hiding this comment

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

Great points! Yes, if we're supporting aria-orientation somehow, I like the idea of using ArrowUp/ArrowDown when aria-orientation="vertical".

|aria-control | Set associate idb.
| role=”tab”| Indicate that is tab. |
| aria-selected| Set for active tab. |
|aria-control | Set associate idb.

Choose a reason for hiding this comment

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

"idb" should be "id"


## Implementation example
| role=”tablist”| Indicate that is tablist. |
| aria-orientation| Indicate horizontally or vertically tab. |

Choose a reason for hiding this comment

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

In the SharePoint version, there was a section for TabPanel:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

<TabPanel>
<div>This is tab three. </div>
</TabPanel>
</Tabs>

Choose a reason for hiding this comment

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

There is a Rendering example in the SharePoint version (appears to be the same as the Implementation example)

Choose a reason for hiding this comment

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

Was the Rendering example not needed?

@Apatil15
Copy link
Contributor Author

@dmedjordan Thank you, I have addressed all the given suggestions

@sh0ji sh0ji changed the title Update RFC_Technical_Design_Document.md Tabs Nov 3, 2021
Copy link
Contributor

@sh0ji sh0ji left a comment

Choose a reason for hiding this comment

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

Thanks for being the brave first RFC, @Apatil15!

Like my general comment in #2, it's not 100% clear to me from this what the API is you're proposing. For instance, should I be able to write code like this and expect it to work?

<TabList>
  <Tab selected aria-controls="panel-animals">Animals</Tab>
  <Tab aria-controls="panel-plants">Plants</Tab>
</TabList>
<p>A persistent paragraph between the tabs and their panels</p>
<TabPanel id="panel-animals">...info about animals...</TabPanel>
<TabPanel id="panel-plants">...info about plants...</TabPanel>

Or what happens if I do this?

<Tabs>
  <TabList selectedIndex={1}>
    <Tab defaultIndex={1} aria-controls="panel-animals">Animals</Tab>
    <Tab disabled aria-controls="panel-plants">Plants</Tab>
  </TabList>
  <TabPanel id="panel-animals">...info about animals...</TabPanel>
  <TabPanel id="panel-plants">...info about plants...</TabPanel>
</Tabs>

I mentioned it in a few comments, but examples like this would go a long way to helping readers understand your design.
@erinoh
#1 Example with selected props not work. We haven't selected property, but on selected event maintaining selected index and based this index selecting a tab.
#2 selectedIndex always override the default index.

|Tab | Focus moves into the tablist from the place of active tab.
|Space or Enter | Activate tab if tabs are not activated.
|Home | Focus move to first tab.
|End | Focus moves to last tab.

## Accessibility
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great in general, thanks for including it! I do think it would be even more effective if required attributes like role or aria-selected were documented under the relevant component rather than in a separate "accessibility" section.

Perhaps each component should have an "Attributes" section that would include attributes that are required for accessibility, but also potentially for other relevant attributes that you'd use to accomplish core functionality like the the disabled HTML attribute to disable a tab...

|aria-control | Set associate idb.
| role=”tab”| Indicate that is tab. |
| aria-selected| Set for active tab. |
|aria-control | Set associate idb.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be aria-controls, and the description could use some work. It would also be great if you linked to the definition in the specification for attributes like this too.

Here's my suggestion, which is more or less the actual specification description for this attribute but specific to the Tabs design you've proposed.

Suggested change
|aria-control | Set associate idb.
| [aria-controls](https://www.w3.org/TR/wai-aria/#aria-controls) | Identifies the `TabPanel` that's being controlled by this `Tab`.

##### Properties

| Props | Type | Default | Required | Description |
| :------------- |:-------------:|:-------------:|:-------------:|:-------------|
| ClassName| Object | | | Override or extend component style.|
Copy link
Contributor

Choose a reason for hiding this comment

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

Right, the onSelected props should be something like, "A callback function that is triggered when a tab is selected."

##### Properties

| Props | Type | Default | Required | Description |
Copy link
Contributor

@sh0ji sh0ji Nov 3, 2021

Choose a reason for hiding this comment

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

I think the diff is off because you accidentally pushed this to main before a branch, so it's not letting me comment on the individual lines. Here are my thoughts about each prop:

  • ClassName - this is presumably already part of the interface that TabListProps extends (React.HTMLAttributes<HTMLDivElement>, maybe? I don't actually know for sure...). If it is part of the extended interface, you don't need to call it out here unless you're changing its functionality in some way.
  • Id - same comment as ClassName.
  • Orientation - props always have to start with a lowercase, so this would be orientation. How's it different from aria-orientation listed right below?
  • SelectedIndex - same comment on casing. What's the benefit of using TabList to control the selected Tab over setting the state on the Tab itself with something like <Tab selected />? If this is a "controlled mode" for the component, you should call that out the fact that it can be controlled or uncontrolled in the design overview above.
  • onSelected - This seems like a very useful prop to me 👍 (it does need a better description, as @dmedjordan pointed out)

@erinoh
aria-orientation : This prop using for accessibility and this props work behind the scene once set orientation prop.

##### Properties

| Props | Type | Default | Required | Description |
| :------------- |:-------------:|:-------------:|:-------------:|:-------------|
| Active| Boolean | | | Selected, Unselected flag, based on this flag active tab.|
Copy link
Contributor

Choose a reason for hiding this comment

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

Right, Active should be selected and its description should probably call out that it sets aria-selected on the tab. The current description is a bit confusing. Maybe, "When set, indicates that the tab is currently selected and its corresponding TabPanel is visible. Sets the aria-selected attribute."

##### Properties

| Props | Type | Default | Required | Description |
| :------------- |:-------------:|:-------------:|:-------------:|:-------------|
| Active| Boolean | | | Selected, Unselected flag, based on this flag active tab.|
Copy link
Contributor

Choose a reason for hiding this comment

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

In addition to the naming and description comment that @dmedjordan made, could you clarify how this works in conjunction with selectedIndex on the TabList? What if I did this?

<TabList selectedIndex={1}>
  <Tab selected>Animals</Tab>  // index={0}
  <Tab>Plants</Tab>            // index={1}
</Tab>

Which way of setting the selected tab wins?

##### Properties

| Props | Type | Default | Required | Description |
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't comment on some of the other props, so here's my feedback:

  • Disabled - this should be inherited by the Tab's underlying interface if possible. In other words, it should just be the disabled HTML attribute, not a new prop that's part of this design. You should call out how you're leveraging existing HTML functionality either in the component summary or in a separate section if you're leveraging a lot of it.
  • defaultIndex - This one's a bit confusing to me. Does it allow you to change the order of the tabs without changing the structural order of the tabs? In other words, would the following be true?
// this JSX:
<Tab defaultIndex={1}>Animals</Tab>
<Tab defaultIndex={0}>Plants</Tab>

// renders to this HTML:
<button role="tab">Plants</button>
<button role="tab">Animals</button>

And if so, could you help me understand why that's necessary?

- nds—tabs (base)
- nds-tabs__tablist
- nds-tabs__tabpanel
- nds—tabs__tab

### Keyboard Intraction
Copy link
Contributor

Choose a reason for hiding this comment

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

I really like this being included here since it's part of what will need to be implemented, but some of this is currently being articulated in the functional design acceptance criteria, isn't it, @dmedjordan? Would you want to merge the two or just use the functional design Jira ticket as the source of truth for expected interaction behaviors like this?


## Implementation example
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd love to see more smaller examples interspersed throughout your design rather than one big one at the end. For instance, under Tab, you could have an example like this:

<Tab selected>Animals</Tab>

// should render to this HTML
<button class="nds-tab" role="tab" aria-selected="true">Animals</button>

I don't know if that's actually accurate to your design, but you hopefully get the idea...smaller examples that tell more of a story.

@sh0ji
Copy link
Contributor

sh0ji commented Aug 23, 2022

Our Tabs design was accepted in #5 so I'm closing this PR.

@sh0ji sh0ji closed this Aug 23, 2022
@sh0ji sh0ji deleted the tabs branch August 23, 2022 16:51
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.

3 participants