-
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
fix(material-experimental/mdc-form-field): fix outline notch width #23005
fix(material-experimental/mdc-form-field): fix outline notch width #23005
Conversation
280e279
to
1bf9ac9
Compare
// Set the vertical alignment for textareas inside form fields to be the middle. This | ||
// ensures that textareas do not stretch the infix container vertically without having | ||
// multiple rows of text. See: https://github.com/angular/components/pull/22089. | ||
vertical-align: middle; |
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.
Are you sure this doesn't mess up prefix/suffix icon alignment?
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.
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.
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.
This is unrelated to this PR (can be observed in Miles' form-field demo too; https://mmalerba-demo-1.web.app/mdc-input). I'll have a look at this in a separate PR; it's also observable on the MDC textfield itself but not as obvious.
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.
Yeah I've noticed that extra line before too, it comes from the MDC styles. I remember having a similar issue back when I was writing our outline form field too.
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.
LGTM, but leaving to Miles for final approval.
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.
LGTM
4882d9f
to
cc8bb0e
Compare
@devversion needs rebase |
cc8bb0e
to
d0f2900
Compare
@mmalerba Done. |
d0f2900
to
74ac140
Compare
Did some more digging. Turns out there used to be |
@wagnermaciel Nice findings. It makes sense that this happens now because our MDC styles for the textarea have increased in specificity. I'd need to look how we can make this work. It seems like even with same specificity of the CDK textarea styles this is prone to break. |
Does that mean this an expected failure? Is this how the text input is meant to look now? |
74ac140
to
23ad76a
Compare
@wagnermaciel It's not expected. I didn't realize this was happening because our examples of the form-field are quite large. Updated the PR to let |
// MDC uses `subtitle1` for the input value, placeholder and floating label. The spec | ||
// shows `body1` for text fields though, so we manually override the typography. | ||
// Note: Form controls inherit the typography from the parent form field. | ||
.mat-mdc-form-field, |
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 think changing these selectors broke some of the typography. I'm seeing a few screenshots in g3 where the font changed. Can we change them back?
23ad76a
to
4384745
Compare
This commit fixes a couple of issues that have been introduced by accident over time: 1. The outline notch width is incorrectly calculated since angular#21676. This happens because we manually override the label's typography level to `body1` but didn't account for the `font-size` set by the `notched-outline`. This resulted in the computed label width being incorrect. 2. angular#22089 added `line-height: 0` to fix textarea's accidentally expanding the infix vertically. This breaks custom controls and their alignment. Textarea's behave a little different compared to a native input, and the actual fix seems to be to fix the alignment from `top` to `middle` so that the infix does not try to add additional padding (due to the inherited `body1` line-height and to satisfy `min-height`). Example: https://jsfiddle.net/rpvm4bkL/6/. 3. Typography has been moved with angular#21676 to the input control (notice how `font: inherit` is removed too). This breaks custom form controls that rely on the typography provided by the form-field (these controls would just inherit typography) 4. Not an actual fix, but a cleanup since 21ab17f added a class to avoid styles from the form-field leaking into standalone inputs. The class has been updated to be more specific that it only matches form-control inputs, and not _any_ type of form control.
4384745
to
707efb6
Compare
…ine-height: normal` on the floating label
b9ef72f
to
aac6264
Compare
…23005) * fix(material-experimental/mdc-form-field): fix outline notch width This commit fixes a couple of issues that have been introduced by accident over time: 1. The outline notch width is incorrectly calculated since #21676. This happens because we manually override the label's typography level to `body1` but didn't account for the `font-size` set by the `notched-outline`. This resulted in the computed label width being incorrect. 2. #22089 added `line-height: 0` to fix textarea's accidentally expanding the infix vertically. This breaks custom controls and their alignment. Textarea's behave a little different compared to a native input, and the actual fix seems to be to fix the alignment from `top` to `middle` so that the infix does not try to add additional padding (due to the inherited `body1` line-height and to satisfy `min-height`). Example: https://jsfiddle.net/rpvm4bkL/6/. 3. Typography has been moved with #21676 to the input control (notice how `font: inherit` is removed too). This breaks custom form controls that rely on the typography provided by the form-field (these controls would just inherit typography) 4. Not an actual fix, but a cleanup since 21ab17f added a class to avoid styles from the form-field leaking into standalone inputs. The class has been updated to be more specific that it only matches form-control inputs, and not _any_ type of form control. * fix(material-experimental/mdc-form-field): increase specificity of `line-height: normal` on the floating label Co-authored-by: Miles Malerba <[email protected]> (cherry picked from commit 04d2aaa)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This commit fixes a couple of issues that have been introduced
by accident over time:
The outline notch width is incorrectly calculated since fix(material-experimental/mdc-typography): update mdc components typography to match spec #21676. This happens because we manually override
the label's typography level to
body1
but didn't account for thefont-size
setby the
notched-outline
. This resulted in the computed label width being incorrect.fix(material-experimental/mdc-form-field): fix height for form field … #22089 added
line-height: 0
to fix textarea's accidentally expanding the infix vertically.This breaks custom controls and their alignment. Textarea's seem to behave a
little different compared to a native input, and the actual fix seems
to be to fix the alignment from
top
tomiddle
so that the infixdoes not try to add additional padding (due to the inherited
body1
line-height and to satisfy
min-height
). Example:https://jsfiddle.net/rpvm4bkL/6/.
Typography has been moved with
fix(material-experimental/mdc-typography): update mdc components typography to match spec #21676 to the
input control (notice how
font: inherit
is removed too). Thisbreaks custom form controls that rely on the typography provided
by the form-field (these controls would just inherit typography)
Not an actual fix, but a cleanup since 21ab17f
added a class to avoid styles from the form-field leaking into
standalone inputs. The class has been updated to be more specific that
it only matches form-control inputs, and not any type of form
control.
Also cleans up logic for the label offset computation. Instead of hard-coding values extracted from MDC, we should have a constant describing where this value comes from. Lastly, deletes a
.swp
file that has sneaked into the repo.