Skip to content

Commit

Permalink
Clear select on skip
Browse files Browse the repository at this point in the history
  • Loading branch information
DingDongSoLong4 committed Sep 23, 2023
1 parent f827379 commit 280fbb2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ui/v2.5/src/components/Tagger/scenes/PerformerResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
stashID.stash_id === performer.remote_site_id
);

const [selectedPerformer, setSelectedPerformer] = useState<
Performer | undefined
>();
const [selectedPerformer, setSelectedPerformer] = useState<Performer>();

useEffect(() => {
if (
Expand All @@ -55,7 +53,7 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
}
}, [performerData?.findPerformer, selectedID]);

const handlePerformerSelect = (performers: Performer[]) => {
const handleSelect = (performers: Performer[]) => {
if (performers.length) {
setSelectedPerformer(performers[0]);
setSelectedID(performers[0].id);
Expand All @@ -65,7 +63,8 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
}
};

const handlePerformerSkip = () => {
const handleSkip = () => {
setSelectedPerformer(undefined);
setSelectedID(undefined);
};

Expand All @@ -82,7 +81,7 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
<OptionalField
exclude={selectedID === undefined}
setExclude={(v) =>
v ? handlePerformerSkip() : setSelectedID(matchedPerformer.id)
v ? handleSkip() : setSelectedID(matchedPerformer.id)
}
>
<div>
Expand Down Expand Up @@ -126,13 +125,13 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
</Button>
<Button
variant={selectedSource === "skip" ? "primary" : "secondary"}
onClick={() => handlePerformerSkip()}
onClick={() => handleSkip()}
>
<FormattedMessage id="actions.skip" />
</Button>
<PerformerSelect
values={selectedPerformer ? [selectedPerformer] : []}
onSelect={handlePerformerSelect}
onSelect={handleSelect}
active={selectedSource === "existing"}
isClearable={false}
/>
Expand Down

0 comments on commit 280fbb2

Please sign in to comment.