parent
5fb8c3575b
commit
78844d7bd5
2 changed files with 59 additions and 33 deletions
|
|
@ -22,6 +22,7 @@ const updateSearchBar = () => {
|
|||
const convertToGroupElements = document.querySelectorAll(".convert_to_group");
|
||||
const convertToGroups = {};
|
||||
const convertToElement = document.querySelector("select[name='convert_to']");
|
||||
const convertButton = document.querySelector("input[type='submit']");
|
||||
|
||||
const showMatching = (search) => {
|
||||
for (const [targets, groupElement] of Object.values(convertToGroups)) {
|
||||
|
|
@ -57,6 +58,7 @@ const updateSearchBar = () => {
|
|||
target.onmousedown = () => {
|
||||
convertToElement.value = target.dataset.value;
|
||||
convertToInput.value = `${target.dataset.target} using ${target.dataset.converter}`;
|
||||
convertButton.disabled = false;
|
||||
showMatching("");
|
||||
};
|
||||
}
|
||||
|
|
@ -68,6 +70,11 @@ const updateSearchBar = () => {
|
|||
showMatching(e.target.value.toLowerCase());
|
||||
});
|
||||
|
||||
convertToInput.addEventListener("search", () => {
|
||||
// when the user clears the search bar using the 'x' button
|
||||
convertButton.disabled = true;
|
||||
});
|
||||
|
||||
convertToInput.addEventListener("blur", (e) => {
|
||||
// Keep the popup open even when clicking on a target button
|
||||
// for a split second to allow the click to go through
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue