Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

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

Merged
merged 8 commits into from
Apr 16, 2018

Conversation

patrickrodee
Copy link
Contributor

@patrickrodee patrickrodee commented Apr 13, 2018

Closes #2550

@codecov-io
Copy link

codecov-io commented Apr 13, 2018

Codecov Report

Merging #2565 into feat/tabs/tabs will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@                Coverage Diff                 @@
##           feat/tabs/tabs    #2565      +/-   ##
==================================================
+ Coverage           98.78%   98.79%   +<.01%     
==================================================
  Files                 103      103              
  Lines                4277     4303      +26     
  Branches              535      536       +1     
==================================================
+ Hits                 4225     4251      +26     
  Misses                 52       52
Impacted Files Coverage Δ
packages/mdc-tab/constants.js 100% <ø> (ø) ⬆️
packages/mdc-tab-indicator/index.js 100% <ø> (ø) ⬆️
packages/mdc-tab-indicator/foundation.js 100% <100%> (ø) ⬆️
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 b5f3406...bc24660. Read the comment docs.

Copy link
Contributor

@lynnmercier lynnmercier left a comment

Choose a reason for hiding this comment

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

You need to update your READMEs too

@@ -27,6 +27,12 @@
}
}

@mixin mdc-tab-indicator-not-upgraded-active_ {
Copy link
Contributor

Choose a reason for hiding this comment

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

The mdc-tab-indicator-active_ mixin is only called within the mdc-tab-indicator.scss file right? Why does the mdc-tab-indicator-not-upgraded-active_ mixin called within the mdc-tab.scss file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mdc-tab-indicator-not-upgraded-active makes the active tab indicator visible until the tab indicator is upgraded and initialized. I'll make it non-private and rename it while also removing mdc-tab-indicator-active as it serves no real purpose.

@@ -84,16 +96,20 @@ class MDCTabFoundation extends MDCFoundation {

/**
* Activates the Tab
* @param {!ClientRect=} previousIndicatorClientRect
Copy link
Contributor

Choose a reason for hiding this comment

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

I forget my closure syntax...but can previousIndicatorClientRect be undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's optional. The = makes it optional (undefined) where as the ? makes it nullable. We want it to be optional in this case.

this.adapter_.registerEventHandler('transitionend', this.handleTransitionEnd_);
this.adapter_.addClass(cssClasses.ANIMATING_ACTIVATE);
this.adapter_.addClass(cssClasses.ACTIVE);
this.adapter_.setAttr(strings.ARIA_SELECTED, 'true');
this.adapter_.setAttr(strings.TABINDEX, '0');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need to add tab-index to the tab when it is activated? Shouldnt tabs always have tab-index?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ARIA tab doc says that only the active tab should be accessible via keyboard focus. There's a good explanation here: https://www.w3.org/TR/wai-aria-practices-1.1/#tabpanel

From the ARIA Tab Example:

Key Function
Tab When focus moves into the tab list, places focus on the active tab element. When the tab list contains the focus, moves focus to the next element in the tab sequence, which is the tabpanel element.
Right Arrow Moves focus to the next tab.If focus is on the last tab, moves focus to the first tab. Activates the newly focused tab.
Left Arrow Moves focus to the previous tab.If focus is on the first tab, moves focus to the last tab. Activates the newly focused tab.
Home Moves focus to the first tab and activates it.
End Moves focus to the last tab and activates it.

this.adapter_.registerEventHandler('transitionend', this.handleTransitionEnd_);
this.adapter_.addClass(cssClasses.ANIMATING_DEACTIVATE);
this.adapter_.removeClass(cssClasses.ACTIVE);
this.adapter_.setAttr(strings.ARIA_SELECTED, 'false');
this.adapter_.setAttr(strings.TABINDEX, '-1');
Copy link
Contributor

Choose a reason for hiding this comment

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

-1 for deactivate? See question above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above comment

* computeIndicatorClientRect: function(): !ClientRect,
* }}
*/
getIndicatorAdapterMethods_() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think you need to make this a separate method. Just move these three methods into the adapter class above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@include mdc-tab-indicator-not-upgraded-active_;
}

.mdc-tab:not(.mdc-tab--stacked) .mdc-tab__icon + .mdc-tab__text-label {
Copy link
Contributor

Choose a reason for hiding this comment

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

this CSS selector is so complicated! whats it doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's setting the left padding of the text label only when it's preceded by an icon. There should only be a left padding when the tab is horizontal (the default state, aka "not stacked").

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I simplified this.

Copy link
Contributor

@lynnmercier lynnmercier left a comment

Choose a reason for hiding this comment

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

LGTM!

#### Active Indicator

```html
<span class="mdc-tab-indicator mdc-tab-indicator--active">
Copy link
Contributor

Choose a reason for hiding this comment

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

actually i think this can just be a CSS class, you dont need the whole HTML structure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@patrickrodee patrickrodee merged commit cf9489b into feat/tabs/tabs Apr 16, 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)
@kfranqueiro kfranqueiro deleted the feat/tabs/tab-indicator-inside-tab branch August 1, 2018 16:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants