mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-19 06:38:45 -05:00
driver: fix typing decimal into number input
This commit is contained in:
@@ -212,6 +212,13 @@ module.exports = (Cypress, Commands) ->
|
||||
|
||||
return dispatched
|
||||
|
||||
needSingleValueChange = ->
|
||||
isDate or
|
||||
isMonth or
|
||||
isWeek or
|
||||
isTime or
|
||||
(options.$el.is("[type=number]") and _.includes(options.chars, "."))
|
||||
|
||||
## see comment in updateValue below
|
||||
typed = ""
|
||||
|
||||
@@ -223,11 +230,11 @@ module.exports = (Cypress, Commands) ->
|
||||
window: @privateState("window")
|
||||
|
||||
updateValue: (rng, key) ->
|
||||
## date/month/week/time inputs need to only have their value updated
|
||||
## once after all the characters are input because attemping
|
||||
## to set a partial/invalid value results in the value being
|
||||
## set to an empty string
|
||||
if isDate or isMonth or isWeek or isTime
|
||||
if needSingleValueChange()
|
||||
## in these cases, the value must only be set after all
|
||||
## the characters are input because attemping to set
|
||||
## a partial/invalid value results in the value being
|
||||
## set to an empty string
|
||||
typed += key
|
||||
if typed is options.chars
|
||||
options.$el.val(options.chars)
|
||||
|
||||
@@ -513,6 +513,10 @@ describe "$Cypress.Cy Text Commands", ->
|
||||
@cy.get("#number-without-value").type("42").then ($text) ->
|
||||
expect($text).to.have.value("42")
|
||||
|
||||
it "can input decimal", ->
|
||||
@cy.get("#number-without-value").type("2.0").then ($input) ->
|
||||
expect($input).to.have.value("2.0")
|
||||
|
||||
it "can utilize {selectall}", ->
|
||||
@cy.get("#number-with-value").type("{selectall}99").then ($input) ->
|
||||
expect($input).to.have.value("99")
|
||||
|
||||
Reference in New Issue
Block a user