Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputNumber: auto send request when focus out if use attribute symbol #3192

Closed
trungdoviet opened this issue Jan 22, 2018 · 8 comments

Comments

Projects
None yet
4 participants
@trungdoviet
Copy link

commented Jan 22, 2018

Usecase

I'm now using Primeface 6.1, as i know that Primefaces already moved some elements from Primefaces Extension to Primefaces and it include p:inputNumber.
Now i have the xhtml like this:

<p:inputNumber   value="#{myBean.amount}"
			minValue="0" decimalPlaces="0">
		 <p:ajax event="change" global="false" listener="#{myBean.doValueChangeEvent}"/>
</p:inputNumber>

It work fine, when i focus in then enter value and focus out, it will fire request to server.
But when i define the symbol for my value (because it's about currency), like this:

<p:inputNumber symbol=" CHF" symbolPosition="s"
 			  value="#{myBean.amount}"
			minValue="0" decimalPlaces="0">
		 <p:ajax event="change" global="false" listener="#{myBean.doValueChangeEvent}"/>
</p:inputNumber>

it mean it will show "CHF" as suffix of my value. When i only focus in and focus out, this element will fire event although i did not input any value (still empty).

1) Environment

  • PrimeFaces version: 6.1
  • It does not work on Primeface 6.2.RC1 as well
  • Application server + version: Tomcat 8.5
  • Affected browsers: IE 11

2) Expected behavior

Should not fire any request in case user does not enter value to inputNumber.

3) Actual behavior

It fire request if i only focus in and focus out without changing value
..

4) Steps to reproduce

  1. Focus in to InputNumber, the suffix will appear
  2. Focus out then request is fired to server

5) Sample XHTML

<p:inputNumber symbol=" CHF" symbolPosition="s"
 			  value="#{myBean.amount}"
			minValue="0" decimalPlaces="0">
		 <p:ajax event="change" global="false" listener="#{myBean.doValueChangeEvent}"/>
</p:inputNumber>

Thanks

@tandraschko

This comment has been minimized.

Copy link
Member

commented Jan 22, 2018

Sorry but it works fine i copy the code in the showcase with the current PF trunk version.

@tandraschko tandraschko changed the title p:inputNumber auto send request when focus out if use attribute symbol InputNumber: auto send request when focus out if use attribute symbol Jan 22, 2018

@Rawi01

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

The current showcase shows exactly the described behaviour. Simply clear the second example input.

@melloware

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

@Rawi01 Clearing the input is not the same as this ticket? This ticket just says focus in and focus out of the element. If you are clearing the value aren't you changing it?

@Rawi01

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

I think I should be more specific :)
I said that you have to clear the field to get an empty input with a symbol as described in this issue.

Steps:

  • Clear input
  • Focus out (Change triggered, as it should)
  • Focus in
  • Focus out (Change triggered again, this is the issue described here)
@melloware

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

Thank you for clarifying!

@melloware

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

@tandraschko can you re-open this ticket. It is definitely a bug in AutoNumeric right here:

if (groupedValue !== holder.inVal || groupedValue !== origValue) {
$this.val(groupedValue);
$this.change();
delete holder.inVal;
}

If you step through the debugger it is saying the values don't match because of the "CHF" suffix and firing the change event.

@Rawi01

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

I just fixed it for my usecase by replacing these lines with

$this.val(groupedValue);
if (groupedValue !== holder.inVal) {
    $this.change();
    delete holder.inVal;
}

The code in autoNumeric were added in this commit: autoNumeric/autoNumeric@553812d

melloware added a commit to melloware/primefaces that referenced this issue Jun 4, 2019

melloware added a commit to melloware/primefaces that referenced this issue Jun 4, 2019

@melloware

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

I agree with your fix and submitted a PR.

melloware added a commit to melloware/primefaces that referenced this issue Jun 5, 2019

@tandraschko tandraschko reopened this Jun 5, 2019

@tandraschko tandraschko removed the invalid label Jun 5, 2019

@melloware melloware added this to the 7.1 milestone Jul 8, 2019

@melloware melloware self-assigned this Jul 8, 2019

@melloware melloware closed this in 571161d Jul 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.