Material-components-web: [Select] Space to underlying form element is reduces when select option is selected

Created on 12 Jul 2019  路  5Comments  路  Source: material-components/material-components-web

Bug report

When a select option is selected the spacing to the underlying element is automatically changed. This bug is visible on the demo site on the outlined enhanced select element.
https://material-components.github.io/material-components-web-catalog/#/component/select

Steps to reproduce

  1. Go to https://material-components.github.io/material-components-web-catalog/#/component/select
  2. Click on outlined enhanced select element
  3. Choose option
  4. Spacing to the underlying elements gets reduced

Actual behavior

Spacing to the underlying element gets reduced.

Expected behavior

The spacing should not be changed.

backlog bug

All 5 comments

This is happening to me as well
Gif of issue: (look closely)
selectBug

Images of inspect view of parent div:
Screen Shot 2019-07-17 at 7 02 09 PM

You can see the 4px under the select when the value is empty

Screen Shot 2019-07-17 at 7 02 21 PM
Now that 4px is gone

The div I'm using is set up like this

<div>
  <div>Some text</div>
  <div class="mdc-select">...</div>
</div>

This happens because .mdc-select__selected-text not have child nodes and browsers add those extra 4px (I not have idea why).
To solve it, .mdc-select__selected-text needs at least one child node (it can be a pseudo element)

This rules solve the problem, also I made a demo

.mdc-select__selected-text{
    display: flex; /*For filled select*/
}
.mdc-select__selected-text::before{
    content: "";
}

This happens because .mdc-select__selected-text not have child nodes and browsers add those extra 4px (I not have idea why).
To solve it, .mdc-select__selected-text needs at least one child node (it can be a pseudo element)

This rules solve the problem, also I made a demo

.mdc-select__selected-text{
  display: flex; /*For filled select*/
}
.mdc-select__selected-text::before{
  content: "";
}

Works perfectly. Will this be part of next release?

I found a more optimal way to remove that extra space using the vertical-align property

.mdc-select{
  vertical-align: middle;
}

This should be fixed after layout overhaul in 28d10a9, which includes changing .mdc-select__anchor from display: inline-flex to display: flex so that the root mdc-select element dictates width.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

traviskaufman picture traviskaufman  路  3Comments

traviskaufman picture traviskaufman  路  3Comments

yapryntsev picture yapryntsev  路  3Comments

traviskaufman picture traviskaufman  路  4Comments

AbuMareBear picture AbuMareBear  路  3Comments