material icon indicating copy to clipboard operation
material copied to clipboard

mdAutocomplete: floating label input padding too large

Open mckenzielong opened this issue 11 years ago • 5 comments

The padding on md-autocomplete does not match other input sizes. See an example here: http://codepen.io/mckenzielong/pen/RWvxQv The text and select boxes have equal spacing, and the md-autocomplete is just slightly larger.

This was introduced after a fix to correct the placement of the progress bar: https://github.com/angular/material/commit/44d1636b27d2dbd873f3844c1e15f9560d188daf

Browser

Opera 33 (Chrome 46) Windows 7, BB10.3.2 webkit

Reproduce

See this code pen: http://codepen.io/mckenzielong/pen/RWvxQv

Suggested fix

Haven't looked at the scss, but only the generated css file... probably isn't this straight forward: remove the 26px padding-bottom and adjust the bottom to be 16px instead of 40px.

mckenzielong avatar Nov 16 '15 19:11 mckenzielong

+1 combined autocomplete height is 94px vs 70px for a regular md-input-container(with text input).

Looks like this line needs to remove the + $input-error-height. My guess is this means special handling for ng-messages is required though. I suspect somehow the padding/margin need to merge a bit so that we can keep that 24px in the padding for ng-messages. https://github.com/angular/material/blob/1a2035b09e54bb6afb94f0e4f20f5d295a4a8838/src/components/autocomplete/autocomplete.scss#L54

A simple fix for now(if you aren't using ng-messages) is to add the following to your scss.

md-autocomplete[md-floating-label] md-input-container {
    padding-bottom: 2px;
}

epelc avatar Nov 16 '15 20:11 epelc

Yes @epelc.

I'm trying to understand the current behavior of the autocomplete directive.

  &[md-floating-label] {
    border-radius: 0;
    background: transparent;
    height: auto;

    md-input-container {
      padding-bottom: $input-container-padding + $input-error-height;

      // When we have ng-messages, remove the input error height from our bottom padding, since the
      // ng-messages wrapper has a min-height of 1 error (so we don't adjust height as often; see
      // input.scss file)
      &.md-input-has-messages {
        padding-bottom: $input-container-padding;
      }
    }

But as we can see there is ngMessage already handled. So why is there the error height added. Does a normal autocomplete without ngMessage support error messages?

devversion avatar Nov 18 '15 10:11 devversion

+1. Have noticed some inconsistencies in the heights of the autocomplete, select and inputs which means we have had to fiddle with CSS to get the padding correct.

pmchugh3 avatar Nov 18 '15 11:11 pmchugh3

Yeah the problem is definitely the floating label at the autocomplete. (&[md-floating-label] md-input-container)

I'm currently hanging on the $input-error-height. It was placed by sense, so we can't remove it without thinking

devversion avatar Nov 18 '15 11:11 devversion

Probably worth mentioning here that not only is the label positioning off, but also the input text.

black = Material Design spec red = current ngMaterial implementation (1.0.0-RC6) image

While aesthetically insignificant on an individual component, when the elements of multiple components' in a form are not aligned, it makes the page look unpolished.

mattdanna avatar Dec 07 '15 22:12 mattdanna