angular / angular/components

feat(select): allow auto-width based on placeholder / value

Abierto
#7,627 12 comentarios 30 reacciones 0 asignados Ver en GitHub
area: material/select feature P3
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

### fixed width on mat-form-field
I want my select to have the width of the selected item, fixed width on mat-form-field makes it impossible, you can override `.mat-form-field` to have `width` `auto`, along with overriding `.mat-select-value` to be `width` `auto` and `max-width` `100%`, but then you have a problem, because placeholder is absolutely positioned, which means that the select without any value set yet will be zero width (actually 18px because of the arrow).

https://stackblitz.com/edit/material2-select-width-issues?file=styles.scss

Now I could also override placeholders not to be absolutely positioned, but that's not gonna work properly either, because the arrow is inside the `md-select` element, while the placeholder is outside

![image](https://user-images.githubusercontent.com/1303561/31315390-330fa1e6-ac18-11e7-8b95-a19923299262.png)

I'm not sure if that 200px width is something that's on material spec, but the DOM could perhaps be structured a bit differently, in a way that wouldn't prevent devs from achieving fluid width (which is a bit closer to how native selects work)

## different height when selected vs. placeholder
![image](https://user-images.githubusercontent.com/1303561/31315458-4a4e4276-ac19-11e7-8d0d-98b9058da2c7.png)

cc @crisbeto

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comience con la reproducción vinculada de StackBlitz e inspeccione la estructura de mat-form-field y mat-select implicada en los casos de fixed-width y placeholder. Compare el comportamiento actual con el comportamiento auto-width solicitado, tanto para un placeholder vacío como para un valor seleccionado; se considera terminado cuando el select puede ajustar su tamaño de forma fluida sin romper el diseño de la flecha ni del placeholder.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
design, frontend
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.