chore: fix issue where popovers & modals are sometimes blurry on chrome
This commit is contained in:
@@ -104,8 +104,7 @@ const Modal = ({
|
||||
/>
|
||||
<div
|
||||
className={classNames(
|
||||
'absolute z-[1] m-0 flex h-full w-full flex-col border-solid border-border bg-default p-0 md:h-auto md:max-h-[85vh] md:w-160 md:rounded md:border md:shadow-main',
|
||||
'md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2 md:transform',
|
||||
'z-[1] m-0 flex h-full w-full flex-col border-solid border-border bg-default p-0 md:h-auto md:max-h-[85vh] md:w-160 md:rounded md:border md:shadow-main',
|
||||
className?.content,
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -42,7 +42,7 @@ const ModalOverlay = forwardRef(
|
||||
return (
|
||||
<Dialog
|
||||
tabIndex={0}
|
||||
className="fixed left-0 top-0 z-modal h-full w-full"
|
||||
className="fixed flex items-center justify-center left-0 top-0 z-modal h-full w-full"
|
||||
ref={mergeRefs([setElement, addCloseMethod, ref])}
|
||||
store={dialog}
|
||||
modal={false}
|
||||
|
||||
@@ -29,8 +29,8 @@ const getStylesFromRect = (
|
||||
|
||||
return {
|
||||
willChange: 'transform',
|
||||
'--translate-x': `${shouldApplyMobileWidth ? marginForMobile / 2 : rect.x}px`,
|
||||
'--translate-y': `${rect.y}px`,
|
||||
'--translate-x': `${shouldApplyMobileWidth ? marginForMobile / 2 : Math.floor(rect.x)}px`,
|
||||
'--translate-y': `${Math.floor(rect.y)}px`,
|
||||
'--offset': `${options.offset}px`,
|
||||
transform: 'translate(var(--translate-x), var(--translate-y))',
|
||||
visibility: 'visible',
|
||||
|
||||
@@ -19,8 +19,8 @@ export const getAdjustedStylesForNonPortalPopover = (
|
||||
|
||||
const parentRect = absoluteParent.getBoundingClientRect()
|
||||
|
||||
const adjustedTranslateX = parsedTranslateX - parentRect.left
|
||||
const adjustedTranslateY = parsedTranslateY - parentRect.top
|
||||
const adjustedTranslateX = Math.floor(parsedTranslateX - parentRect.left)
|
||||
const adjustedTranslateY = Math.floor(parsedTranslateY - parentRect.top)
|
||||
|
||||
return {
|
||||
...styles,
|
||||
|
||||
@@ -8,18 +8,18 @@ export const movePopoverToFitInsideRect = (popoverElement: HTMLElement, rect: DO
|
||||
const overflows = getOverflows(popoverRect, rect)
|
||||
|
||||
if (overflows['top'] > 0) {
|
||||
popoverElement.style.setProperty('--translate-y', `${y + overflows['top'] + offset}px`)
|
||||
popoverElement.style.setProperty('--translate-y', `${Math.floor(y + overflows['top'] + offset)}px`)
|
||||
}
|
||||
|
||||
if (overflows['bottom'] > 0) {
|
||||
popoverElement.style.setProperty('--translate-y', `${y - overflows['bottom'] - offset}px`)
|
||||
popoverElement.style.setProperty('--translate-y', `${Math.floor(y - overflows['bottom'] - offset)}px`)
|
||||
}
|
||||
|
||||
if (overflows['left'] > 0) {
|
||||
popoverElement.style.setProperty('--translate-x', `${x + overflows['left'] + offset}px`)
|
||||
popoverElement.style.setProperty('--translate-x', `${Math.floor(x + overflows['left'] + offset)}px`)
|
||||
}
|
||||
|
||||
if (overflows['right'] > 0) {
|
||||
popoverElement.style.setProperty('--translate-x', `${x - overflows['right'] - offset}px`)
|
||||
popoverElement.style.setProperty('--translate-x', `${Math.floor(x - overflows['right'] - offset)}px`)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user