Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

md-input-container input type="number" field resizes after value input #7349

Closed
kanethal opened this issue Feb 29, 2016 · 8 comments
Closed
Assignees
Labels
has: Pull Request A PR has been created to address this issue P4: minor Minor issues. May not be fixed without community contributions.

Comments

@kanethal
Copy link

Initial placement is fine. Upon entering a number, the field resizes. I tried setting

    md-input-container input[type="number"]{
      width: auto;
      -moz-appearance: textfield;
      -webkit-appearance: textfield;
    }

as per another post (#4864), without results.

image

image

@topherfangio topherfangio added the needs: demo A CodePen demo or GitHub repository is needed to demonstrate the reproduction of the issue label Mar 24, 2016
@topherfangio
Copy link
Contributor

Can you please provide a Codepen showing the issue? Particularly, I'd like to know what your layout/container looks like.

@kanethal
Copy link
Author

Thank you for replying.
Problem is reproduced here: http://codepen.io/kanethal/pen/remgeE

Probably something obvious, thanks for your interest

On Thu, Mar 24, 2016 at 1:16 PM, Topher Fangio notifications@github.com
wrote:

Can you please provide a Codepen showing the issue? Particularly, I'd like
to know what your layout/container looks like.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#7349 (comment)

@topherfangio topherfangio added P4: minor Minor issues. May not be fixed without community contributions. and removed needs: demo A CodePen demo or GitHub repository is needed to demonstrate the reproduction of the issue labels Mar 25, 2016
@topherfangio topherfangio added this to the Backlog milestone Mar 25, 2016
@topherfangio
Copy link
Contributor

@kanethal You can probably use min-width to fix this temporarily, but it definitely seems like a bug.

@crisbeto Can you take a look at this please?

@crisbeto
Copy link
Member

Sure and also wow that's some trippy behaviour.

@kanethal
Copy link
Author

Great thanks, I'm still learning, and it can be tricky to differentiate
between my bad authoring and legit bugs ;).

These were setup to flex. I worked around the sizing issue by changing the
input type to just text. Not sure how to use min-width and maintain the
responsive sizing!

Thanks for your interest, Dan.
On Mar 25, 2016 12:49 PM, "Topher Fangio" notifications@github.com wrote:

@kanethal https://github.com/kanethal You can probably use min-width to
fix this temporarily, but it definitely seems like a bug.

@crisbeto https://github.com/crisbeto Can you take a look at this
please?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#7349 (comment)

@crisbeto crisbeto added the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Mar 26, 2016
@crisbeto
Copy link
Member

This seems to be some kind of strange behaviour in Webkit (IE, Edge and Firefox don't have it, but Chrome, Safari and Opera do) that happens if the input is type="number", has both a min and a max (if it's only one of them it doesn't happen) and is inside a display: flex. The browser seems to set the input width so it can fit the amount of digits in the max +/- a couple of characters and ignores all other widths. For example if you have a max of 999, it resizes to fit ~4-5 characters. In the demo, the width is initially fine because the ng-messages is pushing it out, but when you enter a valid value, the ng-messages get removed from the DOM which makes it collapse.

I didn't manage to hack around it with CSS (e.g. display: block, width: 100%, min-width: 100% etc.) and I didn't find anything in the user agent styles that might be causing this. On the other hand I did find that that setting the step attribute to any fixes the issue, but any other values for step don't.

@topherfangio I'll put in a PR for setting the step to any if both min and max are present.

For future reference, here's a minimal way of reproducing it:

<div layout>
    <input type="number" min="1" max="999">
</div>

@topherfangio
Copy link
Contributor

@crisbeto Wow; that sounds like fun. Out of curiosity, did you test this with a plain number input? I'm wondering if there is something that Material is doing to cause it.

@crisbeto
Copy link
Member

EDIT: Also here's a fiddle https://jsfiddle.net/crisbeto/phm2nuar/1/
Just tried it, it's the same with a plain number input as well.

crisbeto added a commit to crisbeto/material that referenced this issue Mar 26, 2016
Fixes an issue in Webkit browsers where number inputs would collapse to about 1/3 of their proper size, if they're placed in a flexbox and have `min` and `max` attributes.

Fiddle with a simplified example of the issue: https://jsfiddle.net/crisbeto/phm2nuar/3/

Closes angular#7349.
@crisbeto crisbeto added pr: merge ready This PR is ready for a caretaker to review and removed in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs labels Mar 26, 2016
@crisbeto crisbeto modified the milestones: 1.3.0, Backlog Apr 14, 2016
@crisbeto crisbeto added has: Pull Request A PR has been created to address this issue and removed pr: merge ready This PR is ready for a caretaker to review labels Apr 20, 2016
@ThomasBurleson ThomasBurleson modified the milestones: 1.3.0, Backlog Apr 20, 2016
crisbeto added a commit to crisbeto/material that referenced this issue Jun 1, 2016
Fixes an issue in Webkit browsers where number inputs would collapse to about 1/3 of their proper size, if they're placed in a flexbox and have `min` and `max` attributes.

Fiddle with a simplified example of the issue: https://jsfiddle.net/crisbeto/phm2nuar/3/

Closes angular#7349.
@Splaktar Splaktar removed this from the - Backlog milestone Feb 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has: Pull Request A PR has been created to address this issue P4: minor Minor issues. May not be fixed without community contributions.
Projects
None yet
Development

No branches or pull requests

5 participants