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:
@@ -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}%`,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user