Skip to content

Commit 1cb36d8

Browse files
committed
fix: handle scenario where picker can appear offscreen right
1 parent 05ed8a8 commit 1cb36d8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

module/date-picker.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,21 @@ export class DatePicker {
463463
const left = rect.left + window.pageXOffset
464464

465465
const pickerRect = this.picker.getBoundingClientRect()
466+
const pickerRight = left + pickerRect.width
466467
const pickerBottom = top + pickerRect.height
467468

469+
if (pickerRight > document.body.scrollWidth) {
470+
this.picker.style
471+
.left = `${document.body.scrollWidth - pickerRect.width}px`
472+
} else {
473+
this.picker.style.left = `${left}px`
474+
}
475+
468476
if (pickerBottom > document.body.scrollHeight) {
469-
console.log(top, pickerRect.height, offset)
470477
this.picker.style.top = `${top - pickerRect.height - offset}px`
471478
} else {
472479
this.picker.style.top = `${top + rect.height + offset}px`
473480
}
474-
this.picker.style.left = `${left}px`
475481
}
476482
}
477483

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "manhattan-date-picker",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "Date parsing and picking for form fields.",
55
"engines": {
66
"node": ">=8.9.4"

0 commit comments

Comments
 (0)