From 68ac4c971ef1f41f1a00f409d6152022a6f89833 Mon Sep 17 00:00:00 2001 From: Amandine Arias Date: Tue, 8 Jun 2021 19:30:03 +0200 Subject: [PATCH] fix (accessibility) : FILTER gallery events (#6) --- js/filtres.js | 22 ++++++++++++++++------ propage.html | 5 ++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/js/filtres.js b/js/filtres.js index c607eb7..46f6679 100644 --- a/js/filtres.js +++ b/js/filtres.js @@ -1,7 +1,10 @@ // OUVRE - FERME LISTBOX +// ajoute / retire attributs document.querySelector('.filter').addEventListener('click', () => { document.querySelector('.filter__box').classList.toggle('open'); - document.querySelector('.filter__box').removeAttribute('aria-expanded', 'false'); + document + .querySelector('.filter__box') + .removeAttribute('aria-expanded', 'false'); if (document.querySelector('.filter__box').classList.contains('open')) document .querySelector('.filter__box') @@ -10,12 +13,19 @@ document.querySelector('.filter').addEventListener('click', () => { document .querySelector('.filter__box') .setAttribute('aria-expanded', 'false'); + + // ajuste apparence + if (optionTitre.classList.contains('selected')) + optionDate.style.borderRadius = '0 0 3px 3px'; }); +// DOM elements const listbox = document.querySelector('[role="listbox"]'); -// console.log(listbox); const options = [...listbox.children]; -// console.log(options); +const optionPop = document.getElementsByClassName('filter__option--1')[0]; +const optionDate = document.getElementsByClassName('filter__option--2')[0]; +const optionTitre = document.getElementsByClassName('filter__option--3')[0]; +const filterBoxOpen = document.getElementsByClassName('open'); // IDENTITFIE OPTION CHOISIE // NAVIGATION SOURIS @@ -36,9 +46,9 @@ listbox.addEventListener('click', (event) => { // FERME LISTBOX SI CLICK HORS BOX window.addEventListener('click', function (e) { - const select = document.querySelector('.filter__box'); - if (!select.contains(e.target)) { - select.classList.remove('open'); + const filterBox = document.querySelector('.filter__box'); + if (!filterBox.contains(e.target)) { + filterBox.classList.remove('open'); } }); diff --git a/propage.html b/propage.html index 35e9eaa..eae6d45 100644 --- a/propage.html +++ b/propage.html @@ -42,7 +42,7 @@ role="combobox" class="filter__box">