Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Wildcard: Menu button component has bad performance and glitching #38262

Closed
vovakulikov opened this issue Jul 5, 2022 · 3 comments · Fixed by #38298
Closed

Wildcard: Menu button component has bad performance and glitching #38262

vovakulikov opened this issue Jul 5, 2022 · 3 comments · Fixed by #38298
Labels
frontend-platform Issues related to our frontend platform, owned collectively by our frontend crew. sourcegraph-refinement-bot webapp

Comments

@vovakulikov
Copy link
Contributor

vovakulikov commented Jul 5, 2022

Background

On the dashboard code insights page we render a lot of insight cards, each card renders a menu button component within the card. This means we render a lot of menu buttons at the same time and since this PR we always render the menu button content elements even if they're not visible (when the menu button isn't open). This increases the number of elements on the page and therefore increases the paint load for the browser.

Screen.Recording.2022-07-05.at.16.30.05.mov

Screenshot 2022-07-05 at 16 30 41

Proposal

We should not render elements that are not visible on the page. As I recall the original fix about rendering elements on the page in order to focus the first available item came from the fact that overwise reach UI does not focus the first available item. I think this is a good sign for us that we should try different components for menu button pattern that doesn't require rendering on the page all time.

@vovakulikov vovakulikov added webapp frontend-platform Issues related to our frontend platform, owned collectively by our frontend crew. wildcard-v2/menu labels Jul 5, 2022
@sourcegraph-bot-2
Copy link
Collaborator

Heads up @taylorsperry @jasongornall - the "team/frontend-platform" label was applied to this issue.

@umpox
Copy link
Contributor

umpox commented Jul 6, 2022

(Copied from Slack): https://sourcegraph.slack.com/archives/C01LTKUHRL3/p1657100075260849?thread_ts=1657053300.433479&cid=C01LTKUHRL3

It seems this is primarily because we run the render / positioning logic on these elements.

This change fixes it, I think. Maybe could even do it earlier before render is even called so we don’t repeat this logic every event loop

The question is just, do we need to be running positioning logic on hidden elements? I wonder if this could cause future perf issues elsewhere

@vovakulikov LMK what you think, maybe I’ve missed something obvious - happy to revert if we can’t get a nice solution here

@vovakulikov
Copy link
Contributor Author

vovakulikov commented Jul 6, 2022

@umpox I also was thinking about this, but the problem remains even if we have an early return here. I think we should investigate more in this more to have a proper solution, maybe even change the API of tether logic.

But to be honest I could catch this bug only in Safari. And freezes that I could see I saw them only in Safari as well, so we probably can go without reverting a11y PR about the menu here if the frontend platform team has time to fix it in the near future. I can help with that of course, I think you are right about not running position logic if the target element is hidden. I also think that mutations that we're doing inside of tether over target and popover elements might be a reason for glitching in safari.

Screen.Recording.2022-07-06.at.11.06.53.mov

@umpox umpox moved this to Done in Frontend Platform Jul 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frontend-platform Issues related to our frontend platform, owned collectively by our frontend crew. sourcegraph-refinement-bot webapp
Projects
No open projects
Status: Done
4 participants