mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
1 line
5.4 KiB
JavaScript
1 line
5.4 KiB
JavaScript
"use strict";(self.rspackChunkwebsite=self.rspackChunkwebsite||[]).push([["8353"],{2936(e,i,s){s.r(i),s.d(i,{default:()=>l});var r=s(4848),n=s(8453),c=s(7425);function t(e){let i={a:"a",code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",span:"span",ul:"ul",...(0,n.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(i.h1,{id:"accessibility",children:[(0,r.jsx)(i.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#accessibility",children:"#"}),"Accessibility"]}),"\n",(0,r.jsxs)(i.h2,{id:"ishiddenfromaccessibility",children:[(0,r.jsx)(i.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#ishiddenfromaccessibility",children:"#"}),(0,r.jsx)(i.code,{children:"isHiddenFromAccessibility"})]}),"\n",(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(i.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"ts",children:(0,r.jsx)(i.code,{children:(0,r.jsxs)(i.span,{className:"line",children:[(0,r.jsx)(i.span,{style:{color:"var(--shiki-token-keyword)"},children:"function"}),(0,r.jsx)(i.span,{style:{color:"var(--shiki-token-function)"},children:" isHiddenFromAccessibility"}),(0,r.jsx)(i.span,{style:{color:"var(--shiki-foreground)"},children:"(element"}),(0,r.jsx)(i.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,r.jsx)(i.span,{style:{color:"var(--shiki-token-function)"},children:" ReactTestInstance"}),(0,r.jsx)(i.span,{style:{color:"var(--shiki-token-keyword)"},children:" |"}),(0,r.jsx)(i.span,{style:{color:"var(--shiki-token-constant)"},children:" null"}),(0,r.jsx)(i.span,{style:{color:"var(--shiki-foreground)"},children:")"}),(0,r.jsx)(i.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,r.jsx)(i.span,{style:{color:"var(--shiki-token-constant)"},children:" boolean"}),(0,r.jsx)(i.span,{style:{color:"var(--shiki-foreground)"},children:" {}"})]})})})}),"\n",(0,r.jsxs)(i.p,{children:["Also available as ",(0,r.jsx)(i.code,{children:"isInaccessible()"})," alias for React Testing Library compatibility."]}),"\n",(0,r.jsx)(i.p,{children:"Checks if given element is hidden from assistive technology, e.g. screen readers."}),"\n",(0,r.jsxs)(c.Pq,{type:"note",title:"Note",children:[(0,r.jsxs)(i.p,{children:["\nLike the ",(0,r.jsx)(i.a,{href:"https://testing-library.com/docs/dom-testing-library/api-accessibility/#isinaccessible",rel:"noopener noreferrer",target:"_blank",children:(0,r.jsx)(i.code,{children:"isInaccessible"})})," function from DOM Testing Library, this function considers both accessibility elements and presentational elements (regular ",(0,r.jsx)(i.code,{children:"View"}),"s) to be accessible, unless they're hidden in terms of the host platform."]}),(0,r.jsxs)(i.p,{children:["This covers only part of the ",(0,r.jsx)(i.a,{href:"https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion",rel:"noopener noreferrer",target:"_blank",children:"ARIA notion of Accessibility Tree"}),", as ARIA excludes both hidden and presentational elements from the Accessibility Tree."]})]}),"\n",(0,r.jsx)(i.p,{children:"For the scope of this function, element is inaccessible when it, or any of its ancestors, meets any of the following conditions:"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsxs)(i.li,{children:["it has ",(0,r.jsx)(i.code,{children:"display: none"})," style"]}),"\n",(0,r.jsxs)(i.li,{children:["it has ",(0,r.jsx)(i.a,{href:"https://reactnative.dev/docs/accessibility#aria-hidden",rel:"noopener noreferrer",target:"_blank",children:(0,r.jsx)(i.code,{children:"aria-hidden"})})," prop set to ",(0,r.jsx)(i.code,{children:"true"})]}),"\n",(0,r.jsxs)(i.li,{children:["it has ",(0,r.jsx)(i.a,{href:"https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios",rel:"noopener noreferrer",target:"_blank",children:(0,r.jsx)(i.code,{children:"accessibilityElementsHidden"})})," prop set to ",(0,r.jsx)(i.code,{children:"true"})]}),"\n",(0,r.jsxs)(i.li,{children:["it has ",(0,r.jsx)(i.a,{href:"https://reactnative.dev/docs/accessibility#importantforaccessibility-android",rel:"noopener noreferrer",target:"_blank",children:(0,r.jsx)(i.code,{children:"importantForAccessibility"})})," prop set to ",(0,r.jsx)(i.code,{children:"no-hide-descendants"})]}),"\n",(0,r.jsxs)(i.li,{children:["it has sibling host element with either ",(0,r.jsx)(i.a,{href:"https://reactnative.dev/docs/accessibility#aria-modal-ios",rel:"noopener noreferrer",target:"_blank",children:(0,r.jsx)(i.code,{children:"aria-modal"})})," or ",(0,r.jsx)(i.a,{href:"https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios",rel:"noopener noreferrer",target:"_blank",children:(0,r.jsx)(i.code,{children:"accessibilityViewIsModal"})})," prop set to ",(0,r.jsx)(i.code,{children:"true"})]}),"\n"]}),"\n",(0,r.jsxs)(i.p,{children:["Specifying ",(0,r.jsx)(i.code,{children:"accessible={false}"}),", ",(0,r.jsx)(i.code,{children:'accessiblityRole="none"'}),", or ",(0,r.jsx)(i.code,{children:'importantForAccessibility="no"'})," props does not cause the element to become inaccessible."]})]})}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:i}={...(0,n.R)(),...e.components};return i?(0,r.jsx)(i,{...e,children:(0,r.jsx)(t,{...e})}):t(e)}l.__RSPRESS_PAGE_META={},l.__RSPRESS_PAGE_META["13.x%2Fdocs%2Fapi%2Fmisc%2Faccessibility.mdx"]={toc:[{id:"ishiddenfromaccessibility",text:"`isHiddenFromAccessibility`",depth:2}],title:"Accessibility",headingTitle:"Accessibility",frontmatter:{}}}}]); |