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

feat(tab): Give focus to tab when activated #3164

Merged
merged 3 commits into from
Jul 23, 2018

Conversation

patrickrodee
Copy link
Contributor

Closes #3163

@codecov-io
Copy link

codecov-io commented Jul 21, 2018

Codecov Report

❗ No coverage uploaded for pull request base (feat/tabs/tabs@51ae758). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@                Coverage Diff                @@
##             feat/tabs/tabs    #3164   +/-   ##
=================================================
  Coverage                  ?   98.42%           
=================================================
  Files                     ?      113           
  Lines                     ?     4821           
  Branches                  ?      600           
=================================================
  Hits                      ?     4745           
  Misses                    ?       76           
  Partials                  ?        0
Impacted Files Coverage Δ
packages/mdc-tab/foundation.js 100% <100%> (ø)
packages/mdc-tab/index.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51ae758...addb0dc. Read the comment docs.

Copy link
Contributor

@kfranqueiro kfranqueiro left a comment

Choose a reason for hiding this comment

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

Are we sure we want to do this in all cases? Couldn't this be really confusing if you're focused e.g. on a part of the page unaffected by tabs, then a tab is activated programmatically and grabs the user's focus?

@patrickrodee
Copy link
Contributor Author

patrickrodee commented Jul 23, 2018 via email

@kfranqueiro
Copy link
Contributor

I realize this is about keyboard a11y, but that example seems to be showing almost the reverse of what this is doing: the example activates a tab when it receives focus. This PR focuses a tab when it's activated.

There's also another WAI-ARIA example that shows tabs not being activated until space/enter is pressed when they have focus. Our design article seems to show focus states for both activated and unactivated tabs, and our earlier Tabs implementation doesn't activate on focus. Have we talked to a designer about which interaction behavior is intended for Material tabs? I don't see clear guidance on keyboard navigation.

Either way, this PR seems potentially backwards - should we be manipulating focus when arrow keys are used in the tab bar and activating based on focus or space/enter, instead of driving activation off of arrow keys?

@patrickrodee
Copy link
Contributor Author

patrickrodee commented Jul 23, 2018 via email

Copy link
Contributor

@kfranqueiro kfranqueiro left a comment

Choose a reason for hiding this comment

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

Approving for now in the interest of unblocking tab bar, but my reservations stand and we should check with design on what the intended behavior is.

@patrickrodee patrickrodee merged commit 0c5e385 into feat/tabs/tabs Jul 23, 2018
kfranqueiro pushed a commit that referenced this pull request Jul 27, 2018
WIP fixed bg coloring of icons

fix(tab-indicator): Use absolute positioning (#2547)

WIP start of tab scroller

WIP fixed transition duration

WIP progress on scroller

WIP added demos back

chore(tabs): Removed tab scroller

feat(tabs): Add tab indicator inside tab (#2565)

feat(tab-scroller): Add tab scroller (#2577)

Merge master into feat/tabs/tabs (#3096)

feat(tab): Update tab color and typography (#3108)

docs(tabs): Update metadata and synopses (#3117)

feat(tab): Add MDCTabDimensions computation (#3122)

feat(tab): Emit selection and activation events (#3139)

docs(tabs): Update new READMEs to match standard (#3142)

feat(tab): Give focus to tab when activated (#3164)

feat(tab): Add mixin for parent positioning; Use mixin in tab scroller (#3179)

fix(tabs): Suppress area occupied by scrollbar on platforms that show it (#3149)

fix(tab): Remove extraneous padding from the stacked text label in LTR (#3193)

feat(tabs): Add missing docs and create helper util API (#3194)

Merge master into feat/tabs/tabs (#3227)

feat(tab): Update layout; Add fixed-width mixin; Add min-width class (#3220)

fix(tab-scroller): Fix incorrect animation stopping scroll value in RTL (#3237)

feat(tab-scroller): Add scroll content width method for use in tab bar (#3222)

feat(tab): Remove activation event emitting (#3242)

feat(tab-bar): Add tab bar (#3229)
@mathiasschopmans
Copy link
Contributor

tl;dr: Can this behaviour be optional/configurable please?


I am implementing MDC components on a onepage website and (mis)using the tabs as a navigation element in a fixed header, which will scroll the user to some sections of the page.

Additionally, I'm using something like Bootstrap's scrollspy-script to detect whenever the user scrolls to a new section of the page and use instance.activateTab() to mark the current visible section's link (tab) … and this is causing an issue when I'm trying to use the page by keaboard only:

Example:

  • Tabbing: Focus on the tabs. ✔️
  • Tabbing again: Focus is inside a input-element: ✔️
  • Tabbing again: Focus is inside a input element within the next section below the fold
    • Browser scrolls focused element into viewport ✔️
    • Scrollspy script will activate second tab via .activateTab(1) ✔️
    • Focus isn't inside the input-element anymore. Instead tab has focus. ❌

I thought this behaviour could be somehow related to the useAutomaticActivation property, should'nt it, @kfranqueiro? Any help / suggestion would be appreciated. 🙇

@kfranqueiro
Copy link
Contributor

useAutomaticActivation was added in #3303 and is false by default, in which case focusing on tabs shouldn't immediately activate them.

However, it sounds like you have the reverse issue - you're programmatically activating a tab, which gives it focus automatically.

Can you log a separate issue for this? We should probably check with our interaction designers on it.

@kfranqueiro kfranqueiro deleted the feat/tabs/tabs-focus branch September 18, 2018 14:52
@mathiasschopmans
Copy link
Contributor

mathiasschopmans commented Sep 18, 2018

Ah, I see. You're right. In this case useAutomaticActivation shouldn't be used.

However, it sounds like you have the reverse issue - you're programmatically activating a tab, which gives it focus automatically.

Jup, that's my issue. :(

Can you log a separate issue for this?

I will.

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.

4 participants