From cc833e66949bea4cb8c9d905fd2290ade78c7f03 Mon Sep 17 00:00:00 2001 From: codey Date: Sat, 19 Jul 2025 08:01:29 -0400 Subject: [PATCH] bugfix: lyric search excludeSources was not being sent/state issues --- src/components/LyricSearch.jsx | 81 ++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/src/components/LyricSearch.jsx b/src/components/LyricSearch.jsx index d7947af..939f20b 100644 --- a/src/components/LyricSearch.jsx +++ b/src/components/LyricSearch.jsx @@ -44,13 +44,6 @@ export default function LyricSearch() { id="lyric-search-input" placeholder="Artist - Song" setShowLyrics={setShowLyrics} /> -
- Exclude:
-
- - - -
{ + const lower = source.toLowerCase(); setExcludedSources((prev) => - prev.includes(source) - ? prev.filter((s) => s !== source) - : [...prev, source] + prev.includes(lower) + ? prev.filter((s) => s !== lower) + : [...prev, lower] ); }; + // Show scrollable dropdown panel with mouse wheel handling const handlePanelShow = () => { setTimeout(() => { @@ -233,6 +228,13 @@ export function LyricSearchInputField({ id, placeholder, setShowLyrics }) { +
+ Exclude:
+
+ + + +
{isLoading && (
@@ -255,42 +257,47 @@ export function LyricSearchInputField({ id, placeholder, setShowLyrics }) { } -export const UICheckbox = forwardRef(function UICheckbox(opts = {}, ref) { +export const UICheckbox = forwardRef(function UICheckbox(props = {}, ref) { const [checked, setChecked] = useState(false); - const [showAlert, setShowAlert] = useState(false); - let valid_exclusions = true; + useImperativeHandle(ref, () => ({ setChecked: (val) => setChecked(val), checked, })); - - const verifyExclusions = (e) => { - let exclude_error = false; - if (($("#exclude-checkboxes").find("input:checkbox").filter(":checked").length == 3)){ - $("#exclude-checkboxes").find("input:checkbox").each(function () { - exclude_error = true; + + const verifyExclusions = () => { + const checkedCount = $("#exclude-checkboxes input:checkbox:checked").length; + if (checkedCount === 3) { + $("#exclude-checkboxes input:checkbox").each(function () { this.click(); }); - if (exclude_error) { - toast.error("All sources were excluded; exclusions have been reset.", - { style: { backgroundColor: "rgba(255, 0, 0, 0.5)", color: 'inherit' } }, - ); - } + toast.error( + "All sources were excluded; exclusions have been reset.", + { style: { backgroundColor: "rgba(255, 0, 0, 0.5)", color: "inherit" } } + ); } }; - return ( -
- { - setChecked(e.target.checked); - verifyExclusions(); - }} - /> + + const handleChange = (e) => { + const newChecked = e.target.checked; + setChecked(newChecked); + if (props.onToggle) { + const source = props.label; // Use label as source identifier + props.onToggle(source); + } + verifyExclusions(); + }; + + return ( +
+
); });