Skip to content

Commit

Permalink
fix: adjust floating position in Spotlight component for desktop Wind…
Browse files Browse the repository at this point in the history
…ows, OK-34877 (#6568)

* fix: adjust floating position in Spotlight component for desktop Windows

* fix: streamline floating position calculation in Spotlight component for desktop environments
  • Loading branch information
limichange authored Jan 21, 2025
1 parent c2cab98 commit 21ca54a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/kit/src/components/Spotlight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type {
MutableRefObject,
PropsWithChildren,
ReactElement,
ReactNode,
RefObject,
} from 'react';
import {
Expand Down Expand Up @@ -106,6 +105,12 @@ function SpotlightContent({

const measureTriggerInWindow = useCallback(() => {
if (initProps.triggerRef) {
const noNativeNavigator =
platformEnv.isDesktopWin || platformEnv.isDesktopLinux;

// Requires a -30px offset to compensate for window title bar height
const extraY = noNativeNavigator ? -30 : 0;

initProps.triggerRef.current?.measureInWindow((x, y, width, height) => {
if (
floatingPosition.x === x &&
Expand All @@ -117,7 +122,7 @@ function SpotlightContent({
}
setFloatingPosition({
x,
y,
y: y + extraY,
width,
height,
});
Expand Down

0 comments on commit 21ca54a

Please sign in to comment.