emberjs / ember.js

Ember.js - A JavaScript framework for creating ambitious web applications
https://emberjs.com
MIT License
22.47k stars 4.21k forks source link

input helper doesn't respect duplicate values from computed property's setter #12800

Closed kybishop closed 7 years ago

kybishop commented 8 years ago

If you set a maximum within an input's computed property's setter, that maximum is only respected once (via the "increment" button). Once the maximum is exceeded, the input can be set to anything. See this twiddle: https://ember-twiddle.com/859f89dd83561355ccf6?openFiles=application.controller.js%2Capplication.template.hbs

The "maximum only respected once" phenomenon is reset if the number falls back below the computed properties maximum.

Partial workaround: set a max via the max option on the input helper. Pressing two numbers in quick succession (basically spamming numbers on the keyboard) breaks this workaround. The computed property's setter is still entered, but once again, the input doesn't respect the value returned. Full but ugly workaround (hurray puns): In the computed property's setter, call Ember.$('#myInput').val(value);.

pixelhandler commented 8 years ago

@kybishop so yeah this twiddle example seems broke in Chrome, Firefox, but not in Safari. My assumption is that the input type=number element is behaving as expected from the browsers' perspective.

My initial thoughts are that this is not a bug in Ember. I am curious if just using min and max for the number would be better. - http://www.w3.org/TR/html-markup/input.number.html

See: https://ember-twiddle.com/73ad88d26df66bb688b7?openFiles=application.controller.js%2Capplication.template.hbs

{{input type="number" min="0" max="2"  value=myPropertyComputed}}
pixelhandler commented 7 years ago

@kybishop since this issue has a work around and we haven't verified that this is a bug in Ember I'll close this for now. Feel free to reach out for help with a work around in the ember community slack #-help channel - https://embercommunity.slack.com and tool to get an invite to it, https://ember-community-slackin.herokuapp.com/

Feel free to re-open if necessary.