adopted-ember-addons / adopted-ember-addons/ember-paper

Allow paper-input to return a number or date value when the type is number or date

Open
#978 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
879
Forks
327
PR merge metrics
No merged PRs in 30d

Description

I realized that no matter what type is defined for the `paper-input`, it will return a string as a value. There's an easy fix for this in [line 161](https://github.com/miguelcobain/ember-paper/blob/master/addon/components/paper-input.js#L161). Instead of always using `e.target.value` we can use `valueAsNumber` or `valueAsDate` depending on the type:

```js
let value;
if (this.type === "number") {
value = e.target.valueAsNumber;
} else if (this.type === "date") {
value = e.target.valueAsDate;
} else {
value = e.target.value;
}

invokeAction(this, "onChange", value);
```

Is there any drawback that I am not aware of? I will gladly send a PR if you approve this change :smiley:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.