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

Calendar opens and closes on each input event #195

Closed
Enikol opened this issue Dec 13, 2018 · 1 comment
Closed

Calendar opens and closes on each input event #195

Enikol opened this issue Dec 13, 2018 · 1 comment

Comments

@Enikol
Copy link

Enikol commented Dec 13, 2018

Hi!
I'm trying to use datepicker with inputs inside of it, and I ran into an unpleasant bug: each time I click on one of the inputs or press any key, calendar is toggled (shown if it was hidden and vice versa). I reproduced it on codesandbox: https://codesandbox.io/s/4zx1l0n6p4 You can also see the versions of the dependencies I'm using there.
Update: I managed to get it to work by installing version 3.4.0 and replacing two inputs with single input: https://codesandbox.io/s/kwy30z9rl3.
The but I described is probably caused by the addition of the wrapper div in one of the later versions, because bootstrap-daterangepicker checks if the parent of the datepicker is an input/button and apllies the necessary event handlers:

if (this.element.is('input') || this.element.is('button')) {
    this.element.on({
        'click.daterangepicker': $.proxy(this.show, this),
        'focus.daterangepicker': $.proxy(this.show, this),
        'keyup.daterangepicker': $.proxy(this.elementChanged, this),
        'keydown.daterangepicker': $.proxy(this.keydown, this) //IE 11 compatibility
    });
} else {
    this.element.on('click.daterangepicker', $.proxy(this.toggle, this));
    this.element.on('keydown.daterangepicker', $.proxy(this.toggle, this));
}

And since the element in question is a plain div, every click or keypress on the input triggers toggle.

@skratchdot
Copy link
Owner

closing this due to inactivity. please re-open if this is still an issue in v6.0.0 or greater

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants