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(notched-outline): Fix label overflow #4171

Merged
merged 16 commits into from
Jan 4, 2019

Conversation

williamernest
Copy link
Contributor

@williamernest williamernest commented Dec 12, 2018

fixes: #4170
The new notched outline allowed the label to overflow the parent elements, so this causes the label to ellipse when down and to clip when floating.

BREAKING CHANGE: Adds a new adapter API, removeNotchWidthProperty. Also changes the vanilla implementation of MDCFloatingLabelAdapter#getWidth to return scrollWidth rather than offsetWidth.

@codecov-io
Copy link

codecov-io commented Dec 12, 2018

Codecov Report

Merging #4171 into master will decrease coverage by 0.33%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #4171      +/-   ##
=========================================
- Coverage   98.84%   98.5%   -0.34%     
=========================================
  Files         127     127              
  Lines        5629    5631       +2     
  Branches      747     746       -1     
=========================================
- Hits         5564    5547      -17     
- Misses         65      84      +19
Impacted Files Coverage Δ
packages/mdc-notched-outline/foundation.js 100% <100%> (ø) ⬆️
packages/mdc-notched-outline/index.js 100% <100%> (ø) ⬆️
packages/mdc-floating-label/index.js 100% <100%> (ø) ⬆️
packages/mdc-radio/index.js 84.61% <0%> (-12.83%) ⬇️
packages/mdc-tabs/tab/index.js 90.9% <0%> (-9.1%) ⬇️
packages/mdc-switch/index.js 91.83% <0%> (-6.13%) ⬇️
packages/mdc-base/component.js 95.83% <0%> (-4.17%) ⬇️
packages/mdc-tab/index.js 92.98% <0%> (-3.51%) ⬇️
packages/mdc-ripple/util.js 96.49% <0%> (-3.51%) ⬇️
packages/mdc-auto-init/index.js 97.22% <0%> (-2.78%) ⬇️
... and 2 more

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 cb344c3...1bf46a3. 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.

@@ -85,7 +85,13 @@ class MDCNotchedOutline extends MDCComponent {
/** @type {!MDCNotchedOutlineAdapter} */ (Object.assign({
addClass: (className) => this.root_.classList.add(className),
removeClass: (className) => this.root_.classList.remove(className),
setNotchWidthProperty: (width) => this.notchElement_.style.setProperty('width', width > 0 ? width + 'px' : '0'),
setNotchWidthProperty: (width) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be handled in the foundation and exposed as 2 adapter APIs rather than making this one more complex (and less intuitive given its name)?

This is kind of a breaking change regardless of whether we make it 2 APIs or change the behavior of the 1. And if we change it here, we need to document the API's expected behavior. IMO splitting it is simpler to understand by wrapper libraries.

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'll split this up into 2 API's and move the logic to the foundation.

packages/mdc-notched-outline/mdc-notched-outline.scss Outdated Show resolved Hide resolved
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.

LGTM with comments.

Don't forget BREAKING CHANGE: note for the added adapter API.

@@ -55,13 +55,14 @@ test('adapter#addClass adds a class to the root element', () => {
test('adapter#removeClass removes a class to the root element', () => {
const {root, component} = setupTest();
component.getDefaultFoundation().adapter_.removeClass('foo');
assert.isFalse(root.classList.contains('foo'));
component.getDefaultFoundation().adapter_.removeNotchWidthProperty();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the width property actually set on this element before these statements run? Otherwise we're not really verifying anything.


&--upgraded .mdc-floating-label--float-above {
max-width: calc(100% / .75);
text-overflow: clip;
Copy link
Contributor

Choose a reason for hiding this comment

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

(Discussed in DM) Is it safe to apply this even when not upgraded, to avoid the ellipsis appearing then disappearing once JS runs?

@mdc-web-bot
Copy link
Collaborator

@mdc-web-bot
Copy link
Collaborator

@williamernest williamernest merged commit 145db1f into master Jan 4, 2019
@williamernest williamernest deleted the fix/notched-outline/fix-overflow branch January 4, 2019 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MDCNotchedOutline: New version allows label to overflow outline
5 participants