primefaces-extensions / primefaces-extensions

PrimeFaces Extensions
MIT License
111 stars 110 forks source link

InputPhone: ajax event countrySelect show invalid input if triggered by input #1614

Open djmj opened 1 month ago

djmj commented 1 month ago

Describe the bug

In showcase the"countrySelect" ajax is fired on dynamic country detection from input and this should not trigger the input validation but show the info "selected" message.

Reproducer

http://www.primefaces.org/showcase-ext/sections/inputphone/basicUsage.jsf

Expected behavior

With "countrySelect" ajax event it should trigger the info message "country selected". Same behavior as if user selects it from dropdown menu.

PrimeFaces Extensions version

14.0

JSF implementation

None

JSF version

No response

Browser(s)

No response

melloware commented 1 month ago

Ahhh I think I see what you are saying. The Input value should not be processed and trigger a validation warning when only the country is selected.

melloware commented 1 month ago

@djmj why not just do this...use @none

<p:ajax event="countrySelect" process="@none" listener="#{controller.onCountrySelect}"/>

This is how most PF components work and gives you the added flexibility for people who DO want it to validate the submission on country change.

djmj commented 1 month ago

Case A) user entered number

I see your point in case a user already entered a phone number and then changes the country the validation should occur and for this case i want to validate it too.

Example: user switches from germany to austria with a valid phone number

Case B) Input field is still empty

But the case i described is when the user has not entered anything at all in the text input and this is confusing to the user since he has not done anything wrong to be "invalid".

Cant have A and B

Yes this could be a workaround but with a drawback. The workaround will work not work for case A which is not desired but for case B. Cant have both this way.

Internal solution

Can the component itself not check if its fired from event countrySelect and stop validating empty input?

In this showcase its also confusing for the user since the required JSF validator gets triggered while he has just selected a country.

For us its not really important since we dont have a use case for countrySelect but i just wanted to check current state of the component if we shall use it in our application.

melloware commented 1 month ago

@NicolaIsotta @jepsar i also can see this scenario being confusing for users.