Skip to content

Commit

Permalink
Identify input created by FlatpickrEditor as belonging to HOT
Browse files Browse the repository at this point in the history
  • Loading branch information
pkalita-lbl committed Nov 9, 2023
1 parent 49ca5cf commit bc7ed5e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/editors/FlatpickrEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ class FlatpickrEditor extends Handsontable.editors.TextEditor {

this.TEXTAREA = this.hot.rootDocument.createElement('input');
this.TEXTAREA.className = 'handsontableInput';
this.TEXTAREA.setAttribute('data-hot-input', true);
this.textareaStyle = this.TEXTAREA.style;
this.textareaStyle.width = 0;
this.textareaStyle.height = 0;
Handsontable.dom.empty(this.TEXTAREA_PARENT);
this.TEXTAREA_PARENT.innerText = '';
this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);

this.datePicker = this.hot.rootDocument.createElement('DIV');
Expand All @@ -52,10 +53,10 @@ class FlatpickrEditor extends Handsontable.editors.TextEditor {
*/
const eventManager = new Handsontable.EventManager(this);
eventManager.addEventListener(this.datePicker, 'mousedown', (event) => {
Handsontable.dom.stopImmediatePropagation(event);
event.stopPropagation();
});
eventManager.addEventListener(this.datePicker, 'keydown', (event) => {
Handsontable.dom.stopImmediatePropagation(event);
event.stopPropagation();
});
eventManager.addEventListener(this.TEXTAREA, 'keydown', (event) => {
if (event.keyCode === Handsontable.helper.KEY_CODES.ENTER) {
Expand Down Expand Up @@ -112,6 +113,7 @@ class FlatpickrEditor extends Handsontable.editors.TextEditor {
*/
close() {
this._opened = false;
this.fp && this.fp.destroy();
this.removeHooksByKey('beforeKeyDown');
super.close();
}
Expand Down Expand Up @@ -141,8 +143,8 @@ class FlatpickrEditor extends Handsontable.editors.TextEditor {
*/
showDatepicker(event) {
const offset = this.TD.getBoundingClientRect();
const isMouseDown = this.instance.view.isMouseDown();
const isMeta = event ? Handsontable.helper.isMetaKey(event.keyCode) : false;
const isMouseDown = this.hot.view.isMouseDown();
const isMeta = event ? Handsontable.helper.isFunctionKey(event.keyCode) : false;

const defaultConfig = this.getFlatpickrConfig();
const cellConfig =
Expand Down

0 comments on commit bc7ed5e

Please sign in to comment.