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

Multiple mat-icon or mat-icon-button as prefix or suffix are displayed in columns #14311

Open
TFleury opened this issue Nov 28, 2018 · 7 comments
Labels
area: material/button area: material/icon P4 A relatively minor issue that is not relevant to core functions

Comments

@TFleury
Copy link

TFleury commented Nov 28, 2018

Bug:

More than one mat-icon or mat-icon-button as prefix or suffix in a mat-form-field are displayed in columns when appearance is other than 'legacy'.

What is the expected behavior?

They should display in row like in 'legacy' appearance.

What is the current behavior?

They are displayed in column.

What are the steps to reproduce?

https://stackblitz.com/edit/material-multiple-presuffix

What is the use-case or motivation for changing an existing behavior?

Behavior is not consistent accros mat-form-field appearances.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

@angular/material 7.1.0

All browsers.

Is there anything else we should know?

I see 2 solutions :
Solution 1 :
Remove this two rules :

:not(.mat-form-field-appearance-legacy).mat-form-field .mat-form-field-prefix .mat-icon,
:not(.mat-form-field-appearance-legacy).mat-form-field .mat-form-field-suffix .mat-icon {
    display: block;
}
:not(.mat-form-field-appearance-legacy).mat-form-field .mat-form-field-prefix .mat-icon-button,
:not(.mat-form-field-appearance-legacy).mat-form-field .mat-form-field-suffix .mat-icon-button {
    display: block;
}

Solution 2 :
Use flexbox for prefix and suffix :

.mat-form-field-prefix,
.mat-form-field-suffix {
  display: inline-flex;
  align-items: center;
}

Potentially related issues : #11650, #13094, #13322 & #13592

@josephperrott josephperrott added the P4 A relatively minor issue that is not relevant to core functions label Nov 28, 2018
@aennafae
Copy link

Fixed it for me on datepicker outlined input field.
.mat-form-field-flex { align-items: center; }

@TFleury
Copy link
Author

TFleury commented Dec 3, 2018

@aennafae thanks, it's the missing part for solution 2 to work properly.

TFleury added a commit to TFleury/material2 that referenced this issue Dec 3, 2018
…ildren when appearance is other than legacy.

Also fixes a vertical alignment issue of mat-icon-button as pre/suffix in IE and Edge.
Fixes angular#14311, angular#11650, angular#13094, angular#13322 & angular#13592
@BenoitMaisonny
Copy link

Still an issue with Angular 10.0.0:
https://stackblitz.com/edit/angular-mat-form-field-multiple-suffix

@mmalerba
Copy link
Contributor

mmalerba commented Nov 6, 2020

as a workaround for this, use a single matSuffix div and arrange the items inside however you like: https://stackblitz.com/edit/material-multiple-presuffix-u7kax5?file=app%2Fform-field-prefix-suffix-example.html

@am-castro
Copy link

Hi!
in newest versions of material angular use this:

anywhere css

::ng-deep .mat-form-field-prefix,
.mat-form-field-suffix {
  display: inline-flex;
  align-items: center;
}

or add in style.css:

.mat-form-field-prefix,
.mat-form-field-suffix {
  display: inline-flex;
  align-items: center;
}

@mmalerba mmalerba removed the has pr label Dec 8, 2022
@GaetanRdn
Copy link

.mat-form-field-prefix,
.mat-form-field-suffix {
  display: inline-flex;
  align-items: center;
}

for material 15 =>

.mat-mdc-form-field-icon-prefix, .mat-mdc-form-field-icon-suffix { display: inline-flex; align-items: center; }

@neckroot
Copy link

neckroot commented May 24, 2024

mat-icon {
    display: inline;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/button area: material/icon P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
10 participants