Skip to content

Commit 49a4937

Browse files
kevin940726eps1lon
authored andcommitted
feat: Prioritize accessible names check higher than inaccessibility check in byRole queries (testing-library#1068)
Co-authored-by: eps1lon <silbermann.sebastian@gmail.com>
1 parent e713fee commit 49a4937

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/queries/role.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,6 @@ function queryAllByRole(
154154
// don't care if aria attributes are unspecified
155155
return true
156156
})
157-
.filter(element => {
158-
return hidden === false
159-
? isInaccessible(element, {
160-
isSubtreeInaccessible: cachedIsSubtreeInaccessible,
161-
}) === false
162-
: true
163-
})
164157
.filter(element => {
165158
if (name === undefined) {
166159
// Don't care
@@ -177,6 +170,13 @@ function queryAllByRole(
177170
text => text,
178171
)
179172
})
173+
.filter(element => {
174+
return hidden === false
175+
? isInaccessible(element, {
176+
isSubtreeInaccessible: cachedIsSubtreeInaccessible,
177+
}) === false
178+
: true
179+
})
180180
}
181181

182182
function makeRoleSelector(role, exact, customNormalizer) {

0 commit comments

Comments
 (0)