question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Removing focused element inside dialog or dropdown makes CPU spike in chrome.

See original GitHub issue

Bug report

Current Behavior

Removing focused element inside dialog or dropdown makes CPU spike. Possibly due to focus trapping logic.

Bug

Expected behavior

CPU spike shouldn’t happen

Reproducible example

https://codesandbox.io/s/confident-pasteur-30gc2q

Suggested solution

Manually handling focus trap as suggested here works https://github.com/radix-ui/primitives/issues/1498#issuecomment-1194346289

document.addEventListener('focusout', (event) => {
  if (event.relatedTarget === null) container.focus();
})

Additional context

Related issue: https://github.com/radix-ui/primitives/issues/1498#issuecomment-1194346289

This works fine on other OS.

Your environment

Software Name(s) Version
Radix Package(s) Dialog 1.0.0
React n/a 17
Browser Chrome (MacOS) 103.0.5060.53
Assistive tech
Node n/a
npm/yarn
Operating System MacOS all

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:11

github_iconTop GitHub Comments

2reactions
benoitgrelardcommented, Sep 6, 2022

Yeah I see it now. Given that sandbox from @dsdeur, it seems to be a bug in Chrome itself to be honest. We’ll see if we can get around it.

1reaction
benoitgrelardcommented, Sep 6, 2022

If there is a way to disable the automatic focus handling in Radix that triggers the issue it would be relatively easy to work around it and manually handle focus in my app for these cases.

You can do this already on the Content part:

onCloseAutoFocus={event => {
  // focus what you want here, for example the previous item
  previousItemRef.current?.focus();
  event.preventDefault();
}}
Read more comments on GitHub >

github_iconTop Results From Across the Web

10 frustrating Google Chrome irritations and how to fix them
Here, we'll show you how to make Chrome less annoying—and that sweet, serene sanity is worth more than a thousand experimental features.
Read more >
Get actionable insights on your website's performance
For this tutorial, check Disable cache and set CPU to 4x slowdown in the drop-down menu: Throttling. Gotchas. Throttling is relative to your ......
Read more >
5212 - BUG: Chrome does not respond to a mouse click at times
Just a simple right click on a link to open in a new tab, and I'm pounding on my touchpad (or buttons, makes...
Read more >
Set Chrome policies for users or browsers - Google Support
Selecting Enable Active Directory Management lets you manage ChromeOS devices using Microsoft Active Directory or your Admin console. Use the Device management ...
Read more >
CPU limits | Cloud Run Documentation
By default, each container instance is limited to 1 CPU. You can increase this using any integer value up to a maximum of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found