react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

In FocusRing if we give css to focusClass, focus ring is not disappeared on loosing focus

Open upender7270 opened this issue 3 years ago • 2 comments

🐛 Bug Report

In FocusRing if we give CSS to focusClass, CSS is not disappearing after losing focus. When we give CSS to the focusRingClass it is working as expected. But focusRingClass is only for CSS class to apply when the element has keyboard focus, I want mouse actions as well.

🤔 Expected Behavior

When we click outside the button, CSS should be disappeared

😯 Current Behavior

When we click outside the button, CSS is not disappearing

💻 Code Sample

.button {
  -webkit-appearance: none;
  appearance: none;
  background: green;
  border: none;
  color: white;
  font-size: 14px;
  padding: 4px 8px;
}

.button.focus-ring {
  outline: 2px solid dodgerblue;
  outline-offset: 2px;
}
import {FocusRing} from '@react-aria/focus';

<FocusRing focusClass="focus-ring">
  <button className="button">Test</button>
</FocusRing>

Click the tab to focus button and click outside to check.

🌍 Your Environment

Software Version(s)
react-spectrum
Browser Chrome, Brave
Operating System Mac OS, Ubutntu

upender7270 avatar Jul 16 '22 03:07 upender7270

I think you're saying that if you click off with the mouse, the focus ring goes away, but if you click on the button once more after that, the focus ring is visible and it shouldn't be https://codesandbox.io/s/peaceful-dream-7jtwje?file=/src/App.js Which is what I'm seeing here, not sure why though, our docs are working well. This will need some more investigation.

snowystinger avatar Jul 18 '22 17:07 snowystinger

@upender7270 The sandbox @snowystinger attached is actually working as expected, clicking on the background to blur the button removes the focus styles properly. Can you provide your own sandbox reproducing the issue you described?

LFDanLu avatar Aug 03 '22 21:08 LFDanLu

@snowystinger Thanks for putting effort to resolve my issue. I was using @react-aria/focus version 3.4.1. By upgrading to version 3.6.1 issue is resolved.

upender7270 avatar Sep 06 '22 07:09 upender7270