ripjar/material-datetime-picker

When focus is called on an input associated with an already open calendar, stuff breaks, but i have a fix

SamanthaClarke1 opened this issue · 0 comments

Alright, first of all, niche bug.
Second of all, sorry for not pushing through a proper pull request and all that, dont have all that much time.

Rome screws up on it's initialization when you pass through multiple fields (see line 332 (this.initializeRome) of the standalone js)
I triggered this by opening an input, and then navigating to a different window and back, the browser tries to autofocus the input, and it breaks. The specific thing breaking for me was a calendar class, but it seems to be option dependant? Not sure, shouldnt matter.

Fix for me was just this little snippet, to change line 332.

      let tTarget = this.$('.' + this.options.styles.container);
      if(typeof tTarget['length'] != 'undefined' && tTarget.length >= 1) { // if there's multiple returned, we only need the first.
        tTarget = tTarget[0];
      }
      this.initializeRome(tTarget, this.options.dateValidator);