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's onValueChange is called unconditionally when the onBlur event occurs. #1842

Closed
pontasan opened this issue Mar 4, 2021 · 3 comments
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@pontasan
Copy link
Contributor

pontasan commented Mar 4, 2021

There is no guarantee in receiving an immediate response in GitHub Issue Tracker, If you'd like to secure our response, you may consider PrimeReact PRO Support where support is provided within 4 business hours

I'm submitting a ... (check one with "x")

[X] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

The onValueChange callback is called when the onBlur event occurs, regardless of the value change, is this behavior the intended specification?

On the other hand, the onValue event will not be called unless the value changes.
I understand that the only difference between onChange and onValueChange is whether the value passed to the callback has been verified or not.

Reference: #1418

As the following code shows, onValueChange is called by the occurrence of the onBlur event.

    onInputBlur(event) {
        event.persist();
        this.setState({ focused: false }, () => {
            let newValue = this.validateValue(this.parseValue(this.inputEl.value));
            this.updateInputValue(newValue);
            this.updateModel(event, newValue);

            if (this.props.onBlur) {
                this.props.onBlur(event);
            }
        });
    }
    updateModel(event, value) {
        if (this.props.onValueChange) {
            this.props.onValueChange({
                originalEvent: event,
                value: value,
                stopPropagation : () =>{},
                preventDefault : () =>{},
                target: {
                    name: this.props.name,
                    id: this.props.id,
                    value: value
                }
            });
        }
    }

On the other hand, the onChange event will not be called unless the value changes.

    handleOnChange(event, currentValue, newValue) {
        if (this.props.onChange && this.isValueChanged(currentValue, newValue)) {
            this.props.onChange({
                originalEvent: event,
                value: newValue
            });
        }
    }
  • PrimeReact version:
    6.0.2, 5.0.2

  • Language:
    all

@pontasan
Copy link
Contributor Author

pontasan commented May 5, 2021

Dear mertsincan, do you think my views in this issue are wrong?

@mertsincan mertsincan self-assigned this May 5, 2021
@mertsincan mertsincan added the Type: Bug Issue contains a defect related to a specific component. label May 5, 2021
@mertsincan mertsincan added this to the 6.3.2 milestone May 5, 2021
@mertsincan
Copy link
Member

Good catch! Thanks a lot for your info!

Best Regards,

@pontasan
Copy link
Contributor Author

pontasan commented May 5, 2021

Thank you mertsincan for everything. I appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

No branches or pull requests

2 participants