Skip to content

Commit

Permalink
Merge pull request #170 from rrafaelc/fix/bug-click-perguntas
Browse files Browse the repository at this point in the history
fix: bug ao clicar na pergunta na pagina 2 ou mais
  • Loading branch information
rrafaelc committed Nov 22, 2023
2 parents 95e2890 + 14ccf95 commit 47dddff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,12 @@ const renderPerguntas = async ({
});

//efeito no click na pergunta
questionsContainer.addEventListener('click', (e) => {
const questionTitle = e.target.closest('.question-title');
if (questionTitle) {
const dropIcon = questionTitle.querySelector('.drop');
const content = questionTitle.parentElement.nextElementSibling;
const faqContainer = document.querySelectorAll('.faq-container');

faqContainer.forEach((container) => {
container.addEventListener('click', function () {
const dropIcon = container.querySelector('.drop');
const content = container.querySelector('.content');

content.classList.toggle('show');
dropIcon.classList.toggle('rotate');
Expand All @@ -138,7 +139,7 @@ const renderPerguntas = async ({
} else {
content.style.maxHeight = null;
}
}
});
});
} catch (error) {
toast('Houve um erro ao carregar as perguntas', true);
Expand Down
13 changes: 7 additions & 6 deletions mais-buscados/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ const renderMaisBuscadas = async ({ pagina = 1, qtdPorPg = 20, order = 'desc' }
.join('');

//efeito no click na pergunta
mostSearchedQuestionsContainer.addEventListener('click', (e) => {
const questionTitle = e.target.closest('.question-title');
if (questionTitle) {
const dropIcon = questionTitle.querySelector('.drop');
const content = questionTitle.parentElement.nextElementSibling;
const faqContainer = document.querySelectorAll('.faq-container');

faqContainer.forEach((container) => {
container.addEventListener('click', function () {
const dropIcon = container.querySelector('.drop');
const content = container.querySelector('.content');

content.classList.toggle('show');
dropIcon.classList.toggle('rotate');
Expand All @@ -92,7 +93,7 @@ const renderMaisBuscadas = async ({ pagina = 1, qtdPorPg = 20, order = 'desc' }
} else {
content.style.maxHeight = null;
}
}
});
});

window.scrollTo({
Expand Down

0 comments on commit 47dddff

Please sign in to comment.