ampersand-input-view icon indicating copy to clipboard operation
ampersand-input-view copied to clipboard

number type is missing step argument

Open Troyhy opened this issue 8 years ago • 2 comments

It is not possible to set step argument without overriding template. This could be handled same way that type change is handled now.

Step argument in input allows decimal number input.

Troyhy avatar Jul 02 '17 19:07 Troyhy

How much code is required to extend ampersand-input-view to support the step attribute? I would argue that this might not belong in the core module, but instead could be achieved through a local, reusable module that extends the base ampersand-input-view.

dhritzkiv avatar Jul 04 '17 14:07 dhritzkiv

Really sorry about this, I forgot the issue.

I think that step argument is needed, because input already supports number as input type. Now you are limited only integer values. Adding code below would allow using decimal numbers also. But if this is not going to be added to core, here is my solution for reference. Sorry about CoffeeScript snippet.

InputView = require('ampersand-input-view')


module.exports = InputView.extend({
  props:
    step: ['string', false, null],

  initialize: () ->
    InputView.prototype.initialize.apply(@, arguments);
    @on('change:step', @handleStepChange, @);

  render: () ->
    InputView.prototype.render.apply(@, arguments);
    @handleStepChange()

  handleStepChange: () ->
    @input.step = @step

})

Troyhy avatar Aug 01 '17 17:08 Troyhy