Skip to content

Handling onChange for Number Type #333

@minkimcello

Description

@minkimcello

I ran into an issue for number input fields with an onChange that directly invokes a set transition. This prevents the user from inputting decimals because 123. would immediately return 123 as demonstrated here:

2019-03-18 16 01 36

This isn't a problem when using an onBlur or a form, but I've been using the solution below for cases where onChange is necessary:

class NumberInput{
   get value(){
      return valueOf(this)
   }
   get state(){
      return +valueOf(this)
   }
}

Is there a more appropriate way around this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions