-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Focussing an element doesn't trigger the CSS update based on the :focus pseudo class #3359
Comments
Just to be sure, I'm not 100% confident that in the browser it's working as it should. When calling |
@MatanBobi Yes, for me it does work. Using https://codesandbox.io/s/jsdom-focus-sibling-combinator-ph3tql?file=/index.html I can hide the sibling item through focusing the input via console. hide_on_focus.mov |
@Vac1911 That is interesting/worrying. Because it does work in the original window. And it still works when I actually click inside So to me it seems that |
@tbelch-at-eHealth-Tec Yes that's what I was trying to communicate. As far as I know |
I'm having a similar issue. I have an input with a gray border, when I focus I change it to black: export const Input = styled.input`
border-color: gray;
:focus {
border-color: black;
}
` When testing this input, hoping it has focus, it works it('should have a specif border color when focused', async () => {
const user = userEvent.setup()
await user.click(screen.queryByRole('textbox'))
expect(screen.queryByRole('textbox')).toHaveFocus()
}) But when I add the expectation that the style applies to the focus: it('should have a specif border color when focused', async () => {
const user = userEvent.setup()
await user.click(screen.queryByRole('textbox'))
expect(screen.queryByRole('textbox')).toHaveFocus()
expect(screen.queryByRole('textbox')).toHaveStyle(`border-color: black;`)
}) I get that: You can see that the |
I have the same problem as the fine people above ☝️ |
Look like this is related to https://github.com/dperini/nwsapi logic, but from my investigations, this moment should be fine.
|
Dear jsdom team,
I'm trying to achieve the following:
Using the CSS pseudo class
:focus
to determine whether an element has the styledisplay: block
ornone
. I expect the styling of the sibling component to change, when the controlling component is focused. The same way it happens in the browser.Basic info:
Minimal reproduction case
https://codesandbox.io/s/jsdom-focus-sibling-combinator-ph3tql?file=/src/index.js
How does similar code behave in browsers?
In the browser it works as expected. See example
https://codesandbox.io/s/jsdom-focus-sibling-combinator-ph3tql?file=/index.html
The text was updated successfully, but these errors were encountered: