Skip to content

Commit 0f1fded

Browse files
committed
fix: popup not accounting for native titlebar height
fixes #121
1 parent 06f659b commit 0f1fded

File tree

1 file changed

+15
-2
lines changed
  • packages/electron-chrome-extensions/src/browser

1 file changed

+15
-2
lines changed

packages/electron-chrome-extensions/src/browser/popup.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,28 @@ export class PopupView {
202202
if (!this.browserWindow || !this.parent) return
203203

204204
const winBounds = this.parent.getBounds()
205+
const winContentBounds = this.parent.getContentBounds()
206+
const nativeTitlebarHeight = winBounds.height - winContentBounds.height
207+
205208
const viewBounds = this.browserWindow.getBounds()
206209

207210
let x = winBounds.x + this.anchorRect.x + this.anchorRect.width - viewBounds.width
208-
let y = winBounds.y + this.anchorRect.y + this.anchorRect.height + PopupView.POSITION_PADDING
211+
let y =
212+
winBounds.y +
213+
nativeTitlebarHeight +
214+
this.anchorRect.y +
215+
this.anchorRect.height +
216+
PopupView.POSITION_PADDING
209217

210218
// If aligned to a differently then we need to offset the popup position
211219
if (this.alignment?.includes('right')) x = winBounds.x + this.anchorRect.x
212220
if (this.alignment?.includes('top'))
213-
y = winBounds.y - viewBounds.height + this.anchorRect.y - PopupView.POSITION_PADDING
221+
y =
222+
winBounds.y +
223+
nativeTitlebarHeight -
224+
viewBounds.height +
225+
this.anchorRect.y -
226+
PopupView.POSITION_PADDING
214227

215228
// Convert to ints
216229
x = Math.floor(x)

0 commit comments

Comments
 (0)