openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

m.StepInput: "valueState" doesn't stay on focus out

Open boghyon opened this issue 7 years ago • 6 comments

URL (minimal example if possible)

https://jsbin.com/hiwihaw/edit?js,output

Steps to reproduce the problem:

  1. Open the JSBin sample. The initial value of the StepInput is 0 with the valueState "Warning".
  2. Click somewhere else to trigger focusout.

What is the expected result?

The value state stays as "Warning" after focus out.

What happens instead?

On focus out, the value state gets completely overwritten since the value is within the min and max range.

Any other information? (attach screenshot if possible)

https://github.com/SAP/openui5/blob/2a44a832973e480e341128e47a3dd57f5ce5debb/src/sap.m/src/sap/m/StepInput.js#L717-L743

It would be nice if the current valueState is respected and favored over min/max. Other Input controls keep their valueState after focusout (sample). The StepInput should be aligned with them.

boghyon avatar Jan 05 '19 23:01 boghyon

Hello @boghyon , Thank you for sharing this finding. I've created an internal incident 1970012594. The status of the issue will be updated here in GitHub. Regards, Filip.

fifoosid avatar Jan 07 '19 10:01 fifoosid

Hello @boghyon ,

The issue is now fixed. When the user focuses the StepInput and then without changing its value focuses out of it, the valueState remains the same.

However, when the user changes the input value from '2' to '-2' in a StepInput with min property set to '0', the StepInput overrides the 'Warning' valueState (based on the example above) and sets it to 'Error'. Then, if the user changes the value the other way around - from '-2' to '2', the StepInput sets is valueState to 'None'.

Does this interaction of the StepInput control work for you?

Regards, Tereza

terezamch avatar Jun 18 '19 14:06 terezamch

Hi @terezamch,

The issue is now fixed. When the user focuses the StepInput and then, without changing its value, focuses out of it, the valueState remains the same.

Thanks! I can reproduce this behavior. Also the valueState stays after increasing and decreasing the value back with the side buttons. 👍

when the user changes the input value from '2' to '-2' in a StepInput with min property set to '0', the StepInput overrides the 'Warning' valueState (based on the example above) and sets it to 'Error'.

This, however, I can't fully reproduce. When doing so, it overwrites the 'Warning' valueState to 'None' instead of 'Error'. 🤔

Other than that, I guess we can say that the main issue is fixed by now.

boghyon avatar Jun 18 '19 14:06 boghyon

This, however, I can't fully reproduce. When doing so, it overwrites the 'Warning' valueState to 'None' instead of 'Error'. 🤔

Well, based on the above example, it sets to 'None' obviously due to the expression binding in valueState. This is a bit tricky. But in this case, I'd actually expect that the control overwrites the valueState to 'Error' no matter what the app developer has defined in that property if the value exceeds the limit.

boghyon avatar Jun 18 '19 14:06 boghyon

The actual proper solution for the app developer would be to change the expression binding to

valueState="{= ${/steps} === 0 ? 'Warning' : undefined}"

instead of ... 'Warning' : 'None'}". With undefined, it applies the default behavior of the control if the min/max is exceeded --> 'Error'.

So yea, this issue can be closed.

boghyon avatar Jun 18 '19 15:06 boghyon

The issue is now fixed [...]

by https://github.com/SAP/openui5/commit/ca85d4f33ef282eb494f2e9949c8f505dd91f8f4.

boghyon avatar Dec 28 '22 10:12 boghyon