In my current project, I am utilizing Angular Material Components and have been working on customizing mat-select. My goal is to make the select input appear like a dropdown similar to the native HTML select. I have managed to achieve a good effect using only CSS styles, but have encountered an issue.
The problem arises when the appearance of my mat-select varies based on the size of the browser window. Specifically, there are instances where the mat-form-field and mat-select-panel do not align properly (their left sides are not in line) which is unacceptable for the project.
Here is how it should look (example: Firefox browser, window size 100%): https://i.sstatic.net/ruDku.png
And here is what needs fixing (example: Firefox browser, window size 90%): https://i.sstatic.net/c6PUN.png
My analysis of why this is happening: The mat-select-panel has a position absolute that is dependent on the cdk-overlay-panel's dynamic positioning calculation. Sometimes, fractional width and height values get truncated, causing a one-pixel difference between mat-form-field and mat-select-panel. Here is an example:
https://i.sstatic.net/M08jH.png
What I aim to achieve: I am seeking a solution to ensure that my input always maintains a visually pleasing appearance regardless of the browser window size. The alignment between mat-form-field and mat-select-panel must always remain straight.
You can view the Stackblitz for my input here.