JavaScript + BootStrap ์ฌ์ฉ ํ๊ฒฝ์์ ๋ชจ๋ฌ ์ฐฝ์ ๋ซ์ ๋ ๋ธ๋ผ์ฐ์ ๋๊ตฌ์ ๋ค์๊ณผ ๊ฐ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ ๊ฒ์ด ํ์ธ๋์๋ค. ๊ธฐ๋ฅ ๋์์๋ ๋ฌธ์ ๊ฐ ์์ง๋ง, ์ง์์ ์ผ๋ก ๊ฒฝ๊ณ ๊ฐ ๋จ๋ ๋ชจ์ต์ ํด๊ฒฐ์ด ํ์ํ ๊ฒ ๊ฐ์ ์ฐพ์๋ณธ ๋ด์ฉ์ ์ ๋ฆฌํ๋ค.
Blocked aria-hidden on an element because its descendant retained focus. The focus must not be hidden from assistive technology users. Avoid using aria-hidden on a focused element or its ancestor. Consider using the inert attribute instead, which will also prevent focus. For more details, see the aria-hidden section of the WAI-ARIA specification at https://w3c.github.io/aria/#aria-hidden.
Element with focus: button
์ค๋ฅ ์์ธ
๋ชจ๋ฌ์ ๋ซ์ ๋ ์๊ธฐ๋ ์ด Error๋ ๋ชจ๋ฌ ๋ด๋ถ์ ํฌ์ปค์ค๋ ์์๊ฐ ๋จ์ ์๋ ์ํ์์ ์กฐ์ ์์์ aria-hidden="true"๋ฅผ ๊ฑธ์๊ธฐ ๋๋ฌธ์ ๋ฐ์ํ๋ Chromium ๋ฅ ๋ธ๋ผ์ฐ์ ์ ๊ทผ์ฑ(Accessibility) ๊ฒฝ๊ณ ๋ก, ๋ชจ๋ฌ์ ์จ๊ธฐ๊ธฐ ์ง์ ๋ด๋ถ์ ๋จ์ ์๋ ํฌ์ปค์ค๋ฅผ ์ง์ฐ๋ฉด ํด๊ฒฐ๋๋ค.
aria-hidden="true" ์์์ Focus ์ถฉ๋ ๋๋ฌธ์ ๋ฐ์ํ๋ ์๋ฌ์ธ๋ฐ,
์ด๊ฒ ์ ์ฉ๋ ์์๋ ์จ๊ฒจ์ ธ์ผ ํ๋๋ฐ ๊ทธ ์์ ๋ด๋ถ์ ํฌ์ปค์ค๊ฐ ๋จ์ ์์ด ์ ๊ทผ์ฑ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ ๊ฒ.
๋๋ฌธ์, ๋ชจ๋ฌ์ด ๊บผ์ง ๋ ํฌ์ปค์ค๋ฅผ ํด์ ์ํค๋ฉด ์ค๋ฅ๊ฐ ํด๊ฒฐ๋๋ ๊ฒ์ด๋ค.
์ค๋ฅ ์์์ ์ฐพ๋๋ผ ์์นํ ๋๋ถ๋ถ์ ๊ธ์์ aira-hidden์ ์ฌ์ฉํ์ง ์๋ ๊ฒ ์ข๋ค๊ณ ํจ
Accessible Rich Internet Applications (WAI-ARIA) 1.3
A section of a page that consists of a composition that forms an independent part of a document, page, or site. An article is not a navigational landmark, but can be nested to form a discussion where assistive technologies could pay attention to article ne
w3c.github.io
ํด๊ฒฐ ๋ฐฉ๋ฒ
๋ชจ๋ฌ์ ์ฌ์ฉํ๋ ์คํฌ๋ฆฝํธ ๋ด๋ถ ๋๋ ์ ์ญ ์คํฌ๋ฆฝํธ์ ๋ถํธ์คํธ๋ฉ ๋ชจ๋ฌ ์ฌ์ฉ ์ ํฌ์ปค์ค๋ฅผ ํด์ ํ๋ ๊ตฌ๋ฌธ์ ์ถ๊ฐํ๋ค.
// Modal aria-hidden focus ๋ฌธ์ ํด๊ฒฐ
document.addEventListener(
'hide.bs.modal',
function (e) {
const active = document.activeElement;
// activeElement๊ฐ ํ์ฌ ์จ๊ธธ ๋ชจ๋ฌ(e.target) ๋ด๋ถ์ ์์ผ๋ฉด blur
if (e.target.contains(active)) {
active.blur();
}
},
true
);
- hide.bs.modal : ๋ชจ๋ฌ์ด ์จ๊ฒจ์ง๊ธฐ ๋ฐ๋ก ์ง์ ์ ๋ฐ์ํ๋ Event
- document.activeElement : ์ค์ ํฌ์ปค์ค๋ ์๋ฆฌ๋จผํธ๋ฅผ ๊ฐ์ ธ์ blur() ์ฒ๋ฆฌ๋ก ํฌ์ปค์ค๋ฅผ ๋ ๋ฆผ
- true : ์บก์ฒ ๋จ๊ณ๋ก ๋ฑ๋ก / Bootstrap์ hide.bs.modal ๋ด๋ถ ๋ฆฌ์ค๋(๋ณดํต ๋ฒ๋ธ ๋จ๊ณ)๋ณด๋ค ๋จผ์ ์คํ๋์ด aria-hidden="true"๊ฐ ๋ฌ๋ฆฌ๊ธฐ ์ ํฌ์ปค์ค ๋จผ์ ์ ๊ฑฐ
๊ฐ๋ฐ ํ๊ฒฝ์์ ๋ฐ์ํ๋ aria-hidden ์ ๊ทผ์ฑ ๊ฒฝ๊ณ ๊ฐ ์ด์ ํ๊ฒฝ์์๋ ๋ฐ์ํ์ง ์๋ ๊ฑธ ํ์ธํ๊ณ ์กฐ๊ธ ๋ ์์๋ณด๋ ๋ค์๊ณผ ๊ฐ์ ๊ฒฝ์ฐ๋ก ์ธํด ํ๊ฒฝ ์ฐจ์ด์ ๋ฐ๋ผ ๊ฒฝ๊ณ ๊ฐ ๋ ธ์ถ๋์ง ์์ ์ ์๋ค๋ ์ฌ์ค์ ์๊ฒ ๋์๋ค.
- Chrome ์ฑ๋(Stable vs Beta/Canary) ์ฐจ์ด
- ๋ณธ ์๋ฌ๋ Chrome์ ์ ๊ทผ์ฑ(Accessibility) ๊ฒฝ๊ณ ์ธ๋ฐ, ์ด์ ํ๊ฒฝ์ ํฌ๋กฌ ๋ฒ์ ์ 123.0.6312.86v์ผ๋ก aria-hidden ๊ฒ์ฌ ๊ธฐ๋ฅ์ด ์์ ํ ํ์ฑ๋์ง ์์ ๋ฒ์ ์ผ ์ ์๋ค. → ๊ฐ๋ฐ ํ๊ฒฝ๋ณด๋ค ์ด์ ํ๊ฒฝ์ ํฌ๋กฌ ๋ฒ์ ์ด ๋ฎ์ ๋ฐ์ํ๋ ์ฐจ์ด๋ก, ์ต์ ๋น๋์์ ๋ ์๊ฒฉํ ์ ๊ทผ์ฑ ๊ฒฝ๊ณ ๋ฅผ ๋ฟ๋ ์ํฉ์ผ ์ ์์
- DevTools(F12) > Console ์ฐฝ์์ console.log(navigator.userAgent); ๋ช ๋ น์ ์ํํ์ฌ Chrome ๋ฒ์ /์ฑ๋์ ํ์ธํด๋ณด์.
- ARIA ์ฒ๋ฆฌ ํ์ด๋ฐ ์ฐจ์ด
- ๊ฐ๋ฐ ํ๊ฒฝ์ Spring Boot + unminified JS์ธ๋ฐ, ๋ฆฌ์์ค ๋ก๋ฉ/์ฒ๋ฆฌ ์์๊ฐ ์กฐ๊ธ ๋ ๋๋ ค์ hide.bs.modal ์งํ์๋ activeElement๊ฐ ๋จ์ ์๋ ์ํฉ์ด ๋ฐ์ํ ์ ์๋ค.
- ์ด์ ํ๊ฒฝ์ Tomcat 8์ ํจํค์ง๋ minified JS๋ก, ๋ชจ๋ฌ์ด ๋ซํ ๋ ์๋ฐ์คํฌ๋ฆฝํธ๊ฐ ๋ ๋น ๋ฅด๊ฒ ์ฒ๋ฆฌ๋๋ฉด์ ํฌ์ปค์ค๊ฐ ๋จ์ ์์ง ์์ ์ํ๋ก aria-hidden์ด ๋ถ์ด ๊ฒฝ๊ณ ๊ฐ ๋ฐ์ํ์ง ์์ ์ ์๋ค.
- ์ธํฐ๋ท ์ฐ๊ฒฐ ์ ๋ฌด๋ก ์ธํ ์ธ๋ถ ์คํฌ๋ฆฝํธ ์ฐจ์ด
- ์ธํฐ๋ท ์ฐ๊ฒฐ์ด ๊ฐ๋ฅํ ๊ฐ๋ฐ ํ๊ฒฝ์ ๊ฒฝ์ฐ CDN์ผ๋ก๋ถํฐ ๋ถ๊ฐ ํด๋ฆฌํ(inert polyfill)์ด๋ DevTool ํ์ฅ ์คํฌ๋ฆฝํธ๊ฐ ๋ก๋๋ ์ ์๊ณ , ์ฌ๊ธฐ์ ์ถ๊ฐ ๊ฒ์ฌ ๋ก์ง์ด ์คํ๋ ์ ์์ง๋ง, ์ด์ ํ๊ฒฝ์ ์ธํฐ๋ท ์ฐ๊ฒฐ์ด ๋์ง ์์ ์ธ๋ถ ์คํฌ๋ฆฝํธ๋ฅผ ๋ชป ๋ถ๋ฌ์ ๊ฒ์ฌ ํญ๋ชฉ ์์ฒด๊ฐ ๋น ์ ธ ์์ ์ ์๋ค.
๋ํ์ ์ธ ์์ธ์ ์ ๋ฆฌํ ๊ฒ์ธ๋ฐ, ์ด๋ '์ ๊ทผ์ฑ ๊ฒฝ๊ณ '์ผ ๋ฟ์ด๋ ํด๊ฒฐํ์ง ์์๋ ๊ธฐ๋ฅ ๋์์๋ ๋ฌธ์ ๊ฐ ์์ง๋ง ์ ์ฌ์ ์ธ ์ค๋ฅ ์๊ฑด์ด ๋ ์ ์๊ธฐ ๋๋ฌธ์ ํญ์ Warning์ด ๋ฐ์ํ๋ ๊ฐ๋ฐ ํ๊ฒฝ ๊ธฐ์ค์ผ๋ก ์ค๋ฅ๋ฅผ ํด๊ฒฐํ๊ณ ๋ฐ์ํ๋ ๊ฒ ์ข๋ค๊ณ ํ๋จ๋์๋ค.
'๐ป Language > JavaScript : ์๋ฐ์คํฌ๋ฆฝํธ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JavaScript] Rete.js๋? (0) | 2025.03.18 |
---|