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

Handsontable: Date Picker alignment issue in case of last row at bottom of page #3483

Open
ravi590 opened this issue May 11, 2016 · 23 comments

Comments

@ravi590
Copy link

ravi590 commented May 11, 2016

How to change the date picker pop-up opening direction, so it opens upwards if there is not enough space below the edited cell(last row at bottom of page).Can any one help on this ASAP.

@ravi590 ravi590 changed the title Handson Table: Date Picker alignment issue in case of last row at bottom of page Handsontable: Date Picker alignment issue in case of last row at bottom of page May 11, 2016
@AMBudnik
Copy link
Contributor

I think that this should be marked as a change. Currently you don't actually have a choice to allow the date picker to open above the cell.

@ravi590
Copy link
Author

ravi590 commented May 11, 2016

Thanks @AMBudnik, Currently select dropdown is working like that when we verified, only issue is with date picker.

@AMBudnik
Copy link
Contributor

That's right @ravi590 since 0.24.2 we're opening a dropdown list upwards when there's no free space for it.

@Suresh437
Copy link

Hi @AMBudnik , it would be very helpful if any one help on this , my team also facing same issue,

@AMBudnik
Copy link
Contributor

@Suresh437 our developers already know the case so in any spare time this issue should be fixed.

@MariaSpalding
Copy link

Is there any progress on this or information about when it will be implemented? Or any workarounds found?

@AMBudnik
Copy link
Contributor

Hi @thenoune
There's no fix but I was thinking about a possible workaround. We could try to overwrite the htDatepickerHolder class with top and left attributes.

@MariaSpalding
Copy link

MariaSpalding commented Dec 20, 2016

After fiddling with it a little bit I discovered this:

Replace line in handsontable.full.js below where it sets the position of the date picker in

showDatepicker: function(event){ ...
this.datePickerStyle.top = (window.pageYOffset + offset.top + outerHeight(this.TD)) + 'px';
...
}

with the following if statement that checks to see if the position of the cell is within 224px of the bottom of the window and if so, removes 224px from the top measurement.

if (offset.top >= $(window).height() - 224) {
this.datePickerStyle.top = (window.pageYOffset + offset.top - 224 + outerHeight(this.TD)) + 'px';
} else {
this.datePickerStyle.top = (window.pageYOffset + offset.top + outerHeight(this.TD)) + 'px';
}

@AMBudnik
Copy link
Contributor

related: #3957

@AMBudnik AMBudnik added bug and removed enhancement labels Jun 20, 2017
@jgbishop
Copy link

Is there any outlook on a fix for this? This annoyance is one that would be great to solve.

@AMBudnik
Copy link
Contributor

I truly understand that is is not elegant and can be annoying but we did not schedule the issue yet.

@alarie
Copy link

alarie commented Feb 9, 2018

For anybody who faces the same problem and found this issue, here is a little helper class that opens the datepicker to the top if needed:

https://gist.github.com/alarie/e66376ea8e06070864e1ba751043d05a

@cdeepak76
Copy link

For now I updated the offsets of the Date picker Widget

Open handsontable.full.ts and look for below
key: 'showDatepicker',
value: function showDatepicker(event) {

Use the below code (change as per your need) to adjust Date Widget's co-ordinates: In my case the overlap was either for the last cells or because of right hand side overlapping of window border.

  //this.datePickerStyle.top = window.pageYOffset + offset.top + (0, _element.outerHeight)(this.TD) + 'px';
  if (offset.top >= $(window).height() - 224) {
	  this.datePickerStyle.top = (window.pageYOffset + offset.top - 224 + (0, _element.outerHeight)(this.TD)) + 'px';
  } else {
	  this.datePickerStyle.top = (window.pageYOffset + offset.top + (0, _element.outerHeight)(this.TD)) + 'px';
  }
  //this.datePickerStyle.left = window.pageXOffset + offset.left  + 'px';
  this.datePickerStyle.left = (window.pageXOffset + offset.left - 240 + (0, _element.outerWidth)(this.TD)) + 'px';

@Hinaser
Copy link

Hinaser commented Aug 24, 2018

I found another solution.
I will show it to you when I am ready.

@AMBudnik
Copy link
Contributor

inform forum

@lokesh-soni
Copy link

@AMBudnik any update on this issue? Because we are facing same issue. And while trying the to fix the same with some above mentioned solutions we got offset is not defined. Can you please help us with this?

@AMBudnik
Copy link
Contributor

Sorry @lokesh-soni there are no updates on that issue yet

@bmjjr
Copy link

bmjjr commented Mar 16, 2019

The hack from @cdeepak76 makes this issue at least bearable in the short term.

@Jiys
Copy link

Jiys commented May 30, 2019

@lokesh-soni the error was caused by the offset is not defined in you version of handsontable. take a look at var t, n = this.TD.getBoundingClientRect(), replace offset by n. Also don't forget replace _element by d. @cdeepak76 's solution works perfectly fine, you might need to change the pixel value.

@fmaiabatista
Copy link

For anybody who faces the same problem and found this issue, here is a little helper class that opens the datepicker to the top if needed:

https://gist.github.com/alarie/e66376ea8e06070864e1ba751043d05a

Can someone please explain how to properly use @alarie 's gist to make it work? I have tried it and even though I can confirm that the table's instance settings have the editor set up, when I debug the click event it runs the original showDatepicker function from handsontable.js

Using the workaround provided by @cdeepak76 is not an option because we have a git project and handsontable is installed via npm package... so altering the source (handsontable.full.js) is not viable.

@alarie
Copy link

alarie commented Jan 16, 2020

@fmaiabatista I'm not 100% sure because i'm not using the DatePicker anymore in my project, but I think you have to overwrite the editorprop of your column with the DateEditroHelper class from the Gist. See here: https://handsontable.com/docs/7.3.0/frameworks-wrapper-for-vue-custom-editor-example.html

@AMBudnik
Copy link
Contributor

Demo for tests 11.1 https://jsfiddle.net/dL1ae9b7/1/

@AMBudnik
Copy link
Contributor

The datepicker does not change its position in 12.1.3 as well. Updated demo https://jsfiddle.net/g3q64p1a/

Result
date

Here we'd expect the picker to flit and open upwards.

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

No branches or pull requests