Skip to content

Commit

Permalink
fix(QDrawer): QResizeObserver needs to be initialized as soon as poss…
Browse files Browse the repository at this point in the history
…ible otherwise the QLayout totalWidth watcher is called too late for QDrawer #14573
  • Loading branch information
rstoenescu committed Oct 12, 2022
1 parent 885de58 commit 6566781
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions ui/src/components/resize-observer/QResizeObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,21 @@ export default createComponent({
if (hasObserver === true) {
let observer

onMounted(() => {
nextTick(() => {
targetEl = proxy.$el.parentNode
// initialize as soon as possible
const init = stop => {
targetEl = proxy.$el.parentNode

if (targetEl) {
observer = new ResizeObserver(trigger)
observer.observe(targetEl)
emitEvent()
}
})
})
if (targetEl) {
observer = new ResizeObserver(trigger)
observer.observe(targetEl)
emitEvent()
}
else if (stop !== true) {
nextTick(() => { init(true) })
}
}

onMounted(() => { init() })

onBeforeUnmount(() => {
clearTimeout(timer)
Expand Down

0 comments on commit 6566781

Please sign in to comment.