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(material/autocomplete): Prevent Autocomplete overlap with outlined form-field label when overlay is positioned above #27714

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kharazian
Copy link
Contributor

Fixed by preventing Autocomplete overlap with outlined form-field label when overlay is positioned above. Implemented a function to calculate the necessary vertical offset for outlined appearance, ensuring label legibility.

Fix #27476

* Calculate the vertical offset for the overlay when the input field has an outline appearance.
* In the outline appearance, the overlay should have extra space to display the label correctly.
*/
const outlineHeight =
Copy link
Member

Choose a reason for hiding this comment

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

This logic will measure the floating label height even if the form field isn't using the outlined appearance. This should be guarded with the hasOutline check since it has performance implications.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing out the need to optimize this logic. I've first checked _hasOutline() to enhance performance when measuring the floating label height in cases where the form field isn't using the outlined appearance.

@@ -830,9 +830,25 @@ export class MatAutocompleteTrigger
// the opposite end has rounded corners. We apply a CSS class to swap the
// border-radius based on the overlay position.
const panelClass = this._aboveClass;

/**
Copy link
Member

Choose a reason for hiding this comment

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

Should use the // style comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I've made the correction.

@devversion devversion removed their request for review August 28, 2023 11:03
…d label when overlay above

Fixes by preventing Autocomplete overlap with outlined form-field label when overlay is positioned
above. Implemente a function to calculate the necessary vertical offset for outlined appearance,
ensuring label legibility.

Fixes angular#27476
@kharazian kharazian force-pushed the calculate-overlay-offset-for-outlined-input-fields branch from c6f883c to 8f1b1b3 Compare September 27, 2023 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants