Skip to content

Fix find widget alignment #5741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 24, 2025
Merged

Fix find widget alignment #5741

merged 7 commits into from
May 24, 2025

Conversation

RomneyDa
Copy link
Collaborator

@RomneyDa RomneyDa commented May 20, 2025

Fixes find widget match alignment issues caused by tabs by giving the tabs a ref and then passing it to the find widget to account for its height when calculating positions.

@RomneyDa RomneyDa requested a review from a team as a code owner May 20, 2025 02:02
@RomneyDa RomneyDa requested review from tomasz-stefaniak and removed request for a team May 20, 2025 02:02
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 20, 2025
Copy link

netlify bot commented May 20, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit b55079e
🔍 Latest deploy log https://app.netlify.com/projects/continuedev/deploys/68310bc0d520de0008585ca4


// Triggers that should cause results to temporarily disappear and then reload
// Active = LLM is generating, etc.
const active = useAppSelector((state) => state.session.isStreaming);

useEffect(() => {
if (active || isResizing) setMatches([]);
else refreshSearch("none");
}, [refreshSearch, active]);
else setTimeout(() => refreshSearch("none"), 300); // this gives plenty of time for resizing to finish
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a delay for codeblocks etc to render, recalculate search

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will occasionally cause flake. Why is the timeout needed?

rect.top +
searchContainer.clientTop +
searchContainer.scrollTop -
headerHeight;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the main fix - account for header height in result y offset

@tomasz-stefaniak
Copy link
Collaborator

What are the alignment issues? This is what it looks like for me, is that correct?

image

(Some before / after screenshots would be helpful)

};
}, [searchRef.current]);
}, [searchRef, headerRef]);

// Main function for finding matches and generating highlight overlays
const refreshSearch = useCallback(
Copy link
Collaborator

@tomasz-stefaniak tomasz-stefaniak May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refreshSearch is large and complicated as is and useFindWidget is 500 lines long. How about moving this function of FindWidget body?

Suggested change
const refreshSearch = useCallback(
const refreshSearch = useCallback(someNewFunction({
headerRef,
searchRef,
debouncedInput,
scrollToMatch,
caseSensitive,
useRegex,
},
[
headerRef,
searchRef,
debouncedInput,
scrollToMatch,
caseSensitive,
useRegex,
...dependencies,
],
)

@RomneyDa
Copy link
Collaborator Author

@tomasz-stefaniak the issue is with alignment of results, not the widget itself.
Will add a screenshot

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 23, 2025
Copy link
Collaborator

@tomasz-stefaniak tomasz-stefaniak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting up the code into smaller chunks!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 24, 2025
@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs May 24, 2025
@RomneyDa RomneyDa merged commit 50b42f7 into main May 24, 2025
107 of 114 checks passed
@RomneyDa RomneyDa deleted the dallin/find-widget-alignment branch May 24, 2025 01:05
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs May 24, 2025
@github-actions github-actions bot locked and limited conversation to collaborators May 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants