Last active
October 23, 2023 19:45
-
-
Save alarie/e66376ea8e06070864e1ba751043d05a to your computer and use it in GitHub Desktop.
A little extension class of of the Handsontable DateEditor that makes sure the datepicker opens to the top if needed. (Needs modifications for other directions) See https://github.com/handsontable/handsontable/issues/3483
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Base = (Handsontable.editors.DateEditor as any).prototype as any | |
const DateEditorHelper = Base.extend() | |
DateEditorHelper.prototype.showDatepicker = function(...args: any[]) { | |
Base.showDatepicker.apply(this, ...args) | |
const offset = (this.TD as HTMLElement).getBoundingClientRect() | |
const picker = this.$datePicker.el as HTMLElement | |
const pickerRect = picker.getBoundingClientRect() | |
if ( | |
(this.cellProperties && | |
this.cellProperties.datePickerConfig && | |
this.cellProperties.datePickerConfig.position && | |
this.cellProperties.datePickerConfig.position.indexOf("top") !== -1) | |
|| | |
offset.top >= window.innerHeight - pickerRect.height | |
) { | |
this.datePickerStyle.top = (window.pageXOffset + offset.top - pickerRect.height) + "px" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
line 14 should be:
no?
because if you don't have the picker anchored to the top (which you are already checking for) then it is gonna be anchored on the bottom and has an additional offset the height of the TD element