Skip to content

Commit

Permalink
PerformerSelect Tagger bugfixes (stashapp#4148)
Browse files Browse the repository at this point in the history
* Fix Tagger PerformerSelect active highlight
* Clear select on skip
* Add back react-select className
  • Loading branch information
DingDongSoLong4 authored and halkeye committed Sep 1, 2024
1 parent a79beee commit d718932
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 31 deletions.
8 changes: 8 additions & 0 deletions ui/v2.5/src/components/Performers/PerformerSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
MultiValueGenericProps,
SingleValueProps,
} from "react-select";
import cx from "classnames";

import * as GQL from "src/core/generated-graphql";
import {
Expand Down Expand Up @@ -170,6 +171,13 @@ export const PerformerSelect: React.FC<
return (
<FilterSelectComponent<Performer, boolean>
{...props}
className={cx(
"performer-select",
{
"performer-select-active": props.active,
},
props.className
)}
loadOptions={loadPerformers}
getNamedObject={getNamedObject}
isValidNewOption={isValidNewOption}
Expand Down
2 changes: 1 addition & 1 deletion ui/v2.5/src/components/Performers/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,6 @@
}
}

.react-select .alias {
.performer-select .alias {
font-weight: bold;
}
6 changes: 4 additions & 2 deletions ui/v2.5/src/components/Shared/FilterSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import AsyncSelect from "react-select/async";
import AsyncCreatableSelect, {
AsyncCreatableProps,
} from "react-select/async-creatable";
import cx from "classnames";

import { useToast } from "src/hooks/Toast";
import { useDebounce } from "src/hooks/debounce";
Expand Down Expand Up @@ -88,8 +89,8 @@ const SelectComponent = <T, IsMulti extends boolean>(
...props,
styles,
defaultOptions: true,
value: selectedOptions,
className: "react-select",
value: selectedOptions ?? null,
className: cx("react-select", props.className),
classNamePrefix: "react-select",
noOptionsMessage: () => noOptionsMessage,
placeholder: isDisabled ? "" : placeholder,
Expand Down Expand Up @@ -119,6 +120,7 @@ export interface IFilterValueProps<T> {
export interface IFilterProps {
noSelectionString?: string;
className?: string;
active?: boolean;
isMulti?: boolean;
isClearable?: boolean;
isDisabled?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const ScrapedPerformersRow: React.FC<
return (
<PerformerSelect
isMulti
className="form-control react-select"
className="form-control"
isDisabled={!isNew}
onSelect={(items) => {
if (onChangeFn) {
Expand Down
32 changes: 15 additions & 17 deletions ui/v2.5/src/components/Tagger/scenes/PerformerResult.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect, useState } from "react";
import { Button, ButtonGroup } from "react-bootstrap";
import { FormattedMessage } from "react-intl";
import cx from "classnames";

import * as GQL from "src/core/generated-graphql";
import { Icon } from "src/components/Shared/Icon";
Expand Down Expand Up @@ -43,9 +42,12 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
stashID.stash_id === performer.remote_site_id
);

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

function selectPerformer(selected: Performer | undefined) {
setSelectedPerformer(selected);
setSelectedID(selected?.id);
}

useEffect(() => {
if (
Expand All @@ -56,18 +58,16 @@ 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);
selectPerformer(performers[0]);
} else {
setSelectedPerformer(undefined);
setSelectedID(undefined);
selectPerformer(undefined);
}
};

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

if (stashLoading) return <div>Loading performer</div>;
Expand All @@ -83,7 +83,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 @@ -127,16 +127,14 @@ 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}
className={cx("performer-select", {
"performer-select-active": selectedSource === "existing",
})}
onSelect={handleSelect}
active={selectedSource === "existing"}
isClearable={false}
/>
{maybeRenderLinkButton()}
Expand Down
20 changes: 10 additions & 10 deletions ui/v2.5/src/components/Tagger/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@
background-color: hsl(204, 20%, 30%);
cursor: pointer;
}

.performer-select,
.studio-select {
width: 14rem;

// stylelint-disable-next-line selector-class-pattern
&-active .react-select__control {
background-color: #137cbd;
}
}
}

.selected-result {
Expand Down Expand Up @@ -98,16 +108,6 @@
width: 2rem;
}

.performer-select,
.studio-select {
width: 14rem;

// stylelint-disable-next-line selector-class-pattern
&-active .react-select__control {
background-color: #137cbd;
}
}

.entity-name {
flex: 1;
margin-right: auto;
Expand Down

0 comments on commit d718932

Please sign in to comment.