-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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(material-experimental/mdc-tabs): add option to fit ink bar to content #17507
Merged
andrewseguin
merged 3 commits into
angular:master
from
andrewseguin:mdc-tabs-fit-content
Oct 29, 2019
+229
−44
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need the getter here and the setter could be turned into a function. Since this is a private class we don't need to deal with getters and setters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried that approach but I'm not sure I feel as comfortable with it. There are two conditions I need to meet:
To satisfy the first condition, there needs to be a public value
fitToContent
. However, it would not be clear to clients that in order to change this value, they should not write directly to it, but instead use asetFitToContent
function.If clients didn't need to read the value, I'd agree that a setter would work, but in this case I think the getter/setter pattern is ideal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kristiyan is saying that this component (ink bar) is not part of the public API, and as such doesn't need a getter/setter (which we only need for Angular inputs) compared to using functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EDIT: Talked with Jeremy, I did miss that y'all are saying to do "getFitToContent" and "setFitToContent" rather than the ES2015 getter/setter. I'll make the change
OLD REPLY:
Sorry, I see that my explanation may be vague regarding this.
When
fitInkBarToContent
is provided as an input to theMatTabGroup
andMatTabNav
, they store the value into theMatInkBarFoundation
. This will be the source of truth for it's value (not cached in the tab group or nav). When the value is set, the foundation needs to render again, hence the need for a setter (this can be either a native setter orsetFitToContent
).When our users want to access the property
fitInkBarToContent
, we give them the value stored inMatInkBarFoundation
. There are two ways we can do this, expose the propertyfitToContent
, or provide agetFitToContent
function. If we expose the property, it's not clear from theMatTabGroup
/MatTabNav
that it should only use that property for getting, not for setting. In the future, we may make a change and not realize the setter must be used, not the property.If this doesn't make sense, I may be missing what you are proposing. Let's chat in the next team meeting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Andrew and I chatted, he just didn't follow that we meant do e.g.
getFitToContent
andsetFitToContent
instead