Skip to content

Commit 433a2d5

Browse files
authored
Merge pull request #1244 from amnkarn/fix/profile-preview-fix-1240
fix: fix profile preview positioning in search dropdown (#1240)
2 parents b05992f + fc3f661 commit 433a2d5

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

layouts/header/script.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,12 +2576,27 @@ let userDataFunction = async user => {
25762576
});
25772577
shadow.appendChild(div);
25782578

2579-
if(isSticky(el)) {
2579+
if(isSticky(el) && !el.closest('#search-results')) {
25802580
el.after(userPreview);
25812581
} else {
25822582
let rects = el.getBoundingClientRect();
2583-
userPreview.style.top = `${rects.top + window.scrollY+ 20}px`;
2584-
userPreview.style.left = `${rects.left + window.scrollX}px`;
2583+
let topValue;
2584+
2585+
if (el.closest('#search-results')) {
2586+
let searchInput = document.getElementById('search-input');
2587+
let searchRect = searchInput.getBoundingClientRect();
2588+
2589+
topValue = searchRect.top + window.scrollY + 40;
2590+
2591+
userPreview.style.left = `${rects.left + window.scrollX - 320}px`;
2592+
userPreview.style.zIndex = "10000";
2593+
} else {
2594+
topValue = rects.top + window.screenY + 60;
2595+
userPreview.style.left = `${rects.left + window.scrollX}px`;
2596+
}
2597+
2598+
userPreview.style.top = `${topValue}px`;
2599+
25852600
let closestTweet = el.closest('.tweet');
25862601
if(closestTweet) {
25872602
let linkColor = closestTweet.style.getPropertyValue('--link-color');

0 commit comments

Comments
 (0)