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

Ext.form.field.Date fires select event twice #1643

Closed
ggrote opened this issue May 21, 2019 · 3 comments

Comments

@ggrote
Copy link

commented May 21, 2019

In the "onMonthSelect" method the "select" event is fired twice.
At first in the setValue method and again manually via fireEvent.

    onMonthSelect : function (picker, value) {
        var me = this;

        var me = this,
            month = value[0],
            year = value[1],
            date = new Date(year, month, 1);

        if (date.getMonth() !== month) {
            date = new Date(year, month, 1).getLastDateOfMonth();
        }
        
        me.setValue(date);  <- First
        me.fireEvent('select', me, date); <- Second
        me.collapse();
    }
@fabriciomurta fabriciomurta self-assigned this May 21, 2019
@fabriciomurta fabriciomurta added this to the 4.x milestone May 21, 2019
@fabriciomurta

This comment has been minimized.

Copy link
Contributor

commented May 21, 2019

Hello @ggrote!

Thanks for reporting the issue! This issue comes from the specific Ext.NET feature for "month select", when you provide Type="month" to the field settings and is not reproducible with Ext JS alone because it simply doesn't have this config option.

But the component fires select several times (when defocusing, for instance), even if not in "type-month mode", so maybe the best would be to just filter out select events where the value does not change, for instance, with this select event handler:

var handleMonthSelection = function (item, value) {
    overSelectCount++;
    console.log("Select triggered:\nnew: " + value + "\nold: " + item.getValue());
    if (!(this.previousVal instanceof Date) || this.previousVal.getTime() != value.getTime()) {
        uniqSelectCount++;
        this.previousVal = value;
        console.log("Uniq:select ratio: " + uniqSelectCount + ":" + overSelectCount);
    }
}

Anyway, we should fix this issue. We'll post a follow-up here as soon as we get this fixed and slated to the next public release!

@fabriciomurta fabriciomurta modified the milestones: 4.x, 5.0 Sep 12, 2019
@fabriciomurta fabriciomurta added the 5.x label Sep 12, 2019
@fabriciomurta

This comment has been minimized.

Copy link
Contributor

commented Sep 12, 2019

By the way, the "select firing on defocus", or blur, focusLeave; is a bug handled in #1673.

@fabriciomurta

This comment has been minimized.

Copy link
Contributor

commented Sep 12, 2019

The fix for this has just been submit to our 5.0.0 branch, and will be available next release.

We may merge this up to our 4 branch if we make another v4 release in the future.

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