fix: make custom dropdowns and date pickers respect UI zoom setting

Teleported panels read zoom from #app and apply it to their own style,
with position coordinates divided by the zoom factor so they align
correctly with the zoomed trigger elements.
This commit is contained in:
Your Name
2026-02-17 22:35:42 +02:00
parent 40f87c9e04
commit 3dbe4b4ac8
2 changed files with 29 additions and 10 deletions

View File

@@ -64,15 +64,24 @@ function isSelected(item: any): boolean {
return val === props.modelValue
}
function getZoomFactor(): number {
const app = document.getElementById('app')
if (!app) return 1
const zoom = (app.style as any).zoom
return zoom ? parseFloat(zoom) / 100 : 1
}
function updatePosition() {
if (!triggerRef.value) return
const rect = triggerRef.value.getBoundingClientRect()
const zoom = getZoomFactor()
panelStyle.value = {
position: 'fixed',
top: `${rect.bottom + 4}px`,
left: `${rect.left}px`,
width: `${rect.width}px`,
top: `${(rect.bottom + 4) / zoom}px`,
left: `${rect.left / zoom}px`,
width: `${rect.width / zoom}px`,
zIndex: '9999',
zoom: `${zoom * 100}%`,
}
}