-
-
Notifications
You must be signed in to change notification settings - Fork 12
What are the situations "setMenuPosition" runs or reposition the menu #81
Comments
Can you provide some kind of a demo code so I could check the issue? |
sorry can't share the exact code because it's company project, anyway i will try to make a codesandbox demo based on the issue ( it will take some time sorry for that ) |
Tnx, will be fixed in v2.5 |
Investigated your reported issue. So far this is an edge case and I can't provide some uni solution, since it may cause unwanted positioning behavior. In the upcoming version, there will be an option to stack multiple calendars one below another and not in a single row. Or I can also provide an event on position recalculation and you can handle it that way. Would that solve your issue? I can also make a prop that will auto position based on on-screen position, but it may move depending on the window. |
I understood I have to use the multiple calenders as now agendaDpOpen() {
setTimeout(() => {
this.convertHtmlCollectionsToArray()
})
} from there I have to get the convertHtmlCollectionsToArray() {
const shapesHC = document.getElementsByClassName('dp__menu')
const shapesArrHCSpread = [...shapesHC]
if (shapesArrHCSpread) {
this.setDpMenuPosition(shapesArrHCSpread)
}
} if I have the then on setDpMenuPosition(shapesArrHCSpread) {
let dpMenu = shapesArrHCSpread[0]
const el = this.$refs && this.$refs.tcstBuilderAgendaDp
if (el) {
const { right, width } = el.getBoundingClientRect()
const fullWidth = window.innerWidth
const freeSpaceRight = fullWidth - right - width
if (freeSpaceRight < 0) {
const dpMenuStyle = dpMenu.style
dpMenu.children[0].style.left = '90%'
dpMenuStyle.animation = 'slide-out'
dpMenuStyle.animationDuration = '0.5s'
dpMenuStyle.animationDirection = 'forwards'
dpMenuStyle.left = `${right - 239.4}px`
}
}
} this method works well on opening the picker menu, but when i click on next & prev month icon, select a time in a time-picker the position comes to old one, if you can alternate this code a little bit then I'm happy i can manage this issue like this for now. |
Ok, then I will emit an event when the calendar is repositioning, so you can handle the event |
Yep I hope that will work well, thank you, is there any timeline for the 2.5.0 release ? |
At the end of the month, next weekend probably |
@Jasenkoo I tired another trick to fix, it works well Dynamic CSS varible method ( in vue 3 there is a state driven css( v-bind) that won't work here with this picker beacause of the teleport feature ) add a :root {
--leftPos: 0;
} inside const r = document.querySelector(':root') then when there is no free space on the right assign r.style.setProperty('--leftPos', `${right - 239.4}px`) also we need a Boolean to know there is free space on right or not ( this is for adding conditional then we need to add css to do the job .dp-custom-menu-agenda-time {
left: var(--leftPos) !important;
animation: 0.5s forwards slide-out;
}
@keyframes slide-out {
0% {
transform: translateX(0%);
}
100% {
transform: translateX(-50%);
}
} we can add this css class to date-picker component :menuClassName="!hasFreeSpaceRight ? 'dp-custom-menu-agenda-time' : ''" Here is the full code of setDpMenuPosition(shapesArrHCSpread) {
let dpMenu = shapesArrHCSpread[0]
const el = this.$refs && this.$refs.tcstBuilderAgendaDp
const r = document.querySelector(':root')
if (el) {
const { right, width } = el.getBoundingClientRect()
const fullWidth = window.innerWidth
const freeSpaceRight = fullWidth - right - width
if (freeSpaceRight < 0) {
this.hasFreeSpaceRight = false
dpMenu.children[0].style.left = '90%'
r.style.setProperty('--leftPos', `${right - 239.4}px`)
}
}
}, this will do the fixes for now maybe usefull for someone who read this later and I'm also waiting for your |
Will do, thanks 😄 |
- altPosition altered to accept both boolean or function
- altPosition altered to accept both boolean or function
Included in the v2.5.0 |
@Jasenkoo I tried the new version sadly the issue is not resolved
|
@Codefa Ok, then the problem is not in the I've added an option on altPosition prop to pass a custom positioning function. You can use that instead of the |
First of all thanks for this awesome date time picker in vuejs composition API.
Let's come to my issue
I have a carousel with multiple cards each cards have time label at top right, when I click there the date picker opens i can update the date or time that works well, Because of the carousel the last card date picker menu is little bit overflow to the right not visible the select button in viewport i fixed that by calculating the free space to the right side of the browser window and move a bit to the left to adjust the position that too works well, but when I click on any day, click on next,prev Arrow ( month's ) select a tim, then the menu recalculate the position and come back to the real one, how can I fix that ? is your version 2.5 comes as responsive one then that fixes this issue by default ?
The text was updated successfully, but these errors were encountered: