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: "minValue>0 <1" shows js warning #9328

Closed
melloware opened this issue Oct 18, 2022 · 2 comments · Fixed by #9327
Closed

InputNumber: "minValue>0 <1" shows js warning #9328

melloware opened this issue Oct 18, 2022 · 2 comments · Fixed by #9327
Assignees
Labels
🐞 defect Bug...Something isn't working workaround A workaround has been provided
Milestone

Comments

@melloware
Copy link
Member

melloware commented Oct 18, 2022

Originally fixed in #8125

inputNumber is still broken if minValue is a decimal between 0 and 1, just try this to see:

<p:inputNumber minValue="0.01"/>

I think that here:

// GitHub #8125 minValue>0 shows js warning and quirky behavior
if (this.cfg.minimumValue >= 1 || this.cfg.maximumValue < 0) {
this.cfg.overrideMinMaxLimits = 'invalid';
}

the if condition should be:

if (this.cfg.minimumValue > 0.0000001 || this.cfg.maximumValue < 0)

cc @NicolaIsotta

@melloware melloware self-assigned this Oct 18, 2022
@melloware melloware added the 🐞 defect Bug...Something isn't working label Oct 18, 2022
@melloware melloware added this to the 13.0.0 milestone Oct 18, 2022
@melloware melloware linked a pull request Oct 18, 2022 that will close this issue
@melloware
Copy link
Member Author

melloware commented Oct 18, 2022

MOnkeyPatch:

if (PrimeFaces.widget.InputNumber) {
    PrimeFaces.widget.InputNumber.prototype.init = function(cfg) {
        PrimeFaces.widget.BaseWidget.prototype.init.call(this, cfg);
        this.input = $(this.jqId + '_input');
        this.hiddenInput = $(this.jqId + '_hinput');
        this.plugOptArray = cfg.pluginOptions;
        this.valueToRender = cfg.valueToRender;
        this.disabled = cfg.disabled;

        // GitHub #8125 minValue>0 shows js warning and quirky behavior
        if (this.cfg.minimumValue > 0.0000001 || this.cfg.maximumValue < 0) {
            this.cfg.overrideMinMaxLimits = 'invalid';
        }

        //bind events if not disabled
        if (this.disabled) {
            this.input.attr("disabled", "disabled");
            this.input.addClass("ui-state-disabled");
            this.hiddenInput.attr("disabled", "disabled");
        }

        //Visual effects
        PrimeFaces.skinInput(this.input);

        this.wrapEvents();
        this.bindInputEvents();

        this.autonumeric = new AutoNumeric(this.jqId + '_input', this.cfg);

        if (this.valueToRender !== "") {
            //set the value to the input the plugin will format it.
            this.autonumeric.set(this.valueToRender);
            // GitHub #6940 blur firing too many change events
            this.autonumeric.rawValueOnFocus = this.valueToRender;
        }

        this.setValueToHiddenInput(this.getValue());

        //pfs metadata
        this.input.data(PrimeFaces.CLIENT_ID_DATA, this.id);
        this.hiddenInput.data(PrimeFaces.CLIENT_ID_DATA, this.id);
    }
};

@melloware melloware added the workaround A workaround has been provided label Oct 18, 2022
@NicolaIsotta
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 defect Bug...Something isn't working workaround A workaround has been provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants