fixed display issue with select dropdown

This commit is contained in:
David Katrinka 2025-07-05 20:51:43 +02:00
parent a6a7fbade6
commit 4ccb8ac05e
2 changed files with 10 additions and 1 deletions

View File

@ -12,7 +12,7 @@ the_header(
?> ?>
<div id="recipe-id" hidden><?= $context['recipe']->get_id() ?></div> <div id="recipe-id" hidden><?= $context['recipe']->get_id() ?></div>
<div id="in-usermenu" hidden></div> <div id="in-usermenu" hidden><?= $context['recipe']->in_usermenu; ?></div>
<div class="container"> <div class="container">
<div class="single-recipe"> <div class="single-recipe">

View File

@ -15,7 +15,16 @@ document.addEventListener('click', (e) => {
const options = document.querySelectorAll('.dropdown-item'); const options = document.querySelectorAll('.dropdown-item');
const inUsermenu = document.getElementById('in-usermenu').textContent;
if (inUsermenu) {
options.forEach(option => {
if (option.getAttribute('data-value') === inUsermenu && option.getAttribute('data-value') !== 'remove') {
option.classList.add('dropdown-selected');
toggleBtn.textContent = option.textContent;
}
});
}
options.forEach(option => { options.forEach(option => {
option.addEventListener('click', async (e) => { option.addEventListener('click', async (e) => {
const selectedValue = option.getAttribute('data-value'); const selectedValue = option.getAttribute('data-value');