mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
PerformerSelect Tagger bugfixes (#4148)
* Fix Tagger PerformerSelect active highlight * Clear select on skip * Add back react-select className
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
|||||||
MultiValueGenericProps,
|
MultiValueGenericProps,
|
||||||
SingleValueProps,
|
SingleValueProps,
|
||||||
} from "react-select";
|
} from "react-select";
|
||||||
|
import cx from "classnames";
|
||||||
|
|
||||||
import * as GQL from "src/core/generated-graphql";
|
import * as GQL from "src/core/generated-graphql";
|
||||||
import {
|
import {
|
||||||
@@ -170,6 +171,13 @@ export const PerformerSelect: React.FC<
|
|||||||
return (
|
return (
|
||||||
<FilterSelectComponent<Performer, boolean>
|
<FilterSelectComponent<Performer, boolean>
|
||||||
{...props}
|
{...props}
|
||||||
|
className={cx(
|
||||||
|
"performer-select",
|
||||||
|
{
|
||||||
|
"performer-select-active": props.active,
|
||||||
|
},
|
||||||
|
props.className
|
||||||
|
)}
|
||||||
loadOptions={loadPerformers}
|
loadOptions={loadPerformers}
|
||||||
getNamedObject={getNamedObject}
|
getNamedObject={getNamedObject}
|
||||||
isValidNewOption={isValidNewOption}
|
isValidNewOption={isValidNewOption}
|
||||||
|
|||||||
@@ -224,6 +224,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.react-select .alias {
|
.performer-select .alias {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import AsyncSelect from "react-select/async";
|
|||||||
import AsyncCreatableSelect, {
|
import AsyncCreatableSelect, {
|
||||||
AsyncCreatableProps,
|
AsyncCreatableProps,
|
||||||
} from "react-select/async-creatable";
|
} from "react-select/async-creatable";
|
||||||
|
import cx from "classnames";
|
||||||
|
|
||||||
import { useToast } from "src/hooks/Toast";
|
import { useToast } from "src/hooks/Toast";
|
||||||
import { useDebounce } from "src/hooks/debounce";
|
import { useDebounce } from "src/hooks/debounce";
|
||||||
@@ -88,8 +89,8 @@ const SelectComponent = <T, IsMulti extends boolean>(
|
|||||||
...props,
|
...props,
|
||||||
styles,
|
styles,
|
||||||
defaultOptions: true,
|
defaultOptions: true,
|
||||||
value: selectedOptions,
|
value: selectedOptions ?? null,
|
||||||
className: "react-select",
|
className: cx("react-select", props.className),
|
||||||
classNamePrefix: "react-select",
|
classNamePrefix: "react-select",
|
||||||
noOptionsMessage: () => noOptionsMessage,
|
noOptionsMessage: () => noOptionsMessage,
|
||||||
placeholder: isDisabled ? "" : placeholder,
|
placeholder: isDisabled ? "" : placeholder,
|
||||||
@@ -119,6 +120,7 @@ export interface IFilterValueProps<T> {
|
|||||||
export interface IFilterProps {
|
export interface IFilterProps {
|
||||||
noSelectionString?: string;
|
noSelectionString?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
active?: boolean;
|
||||||
isMulti?: boolean;
|
isMulti?: boolean;
|
||||||
isClearable?: boolean;
|
isClearable?: boolean;
|
||||||
isDisabled?: boolean;
|
isDisabled?: boolean;
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ export const ScrapedPerformersRow: React.FC<
|
|||||||
return (
|
return (
|
||||||
<PerformerSelect
|
<PerformerSelect
|
||||||
isMulti
|
isMulti
|
||||||
className="form-control react-select"
|
className="form-control"
|
||||||
isDisabled={!isNew}
|
isDisabled={!isNew}
|
||||||
onSelect={(items) => {
|
onSelect={(items) => {
|
||||||
if (onChangeFn) {
|
if (onChangeFn) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Button, ButtonGroup } from "react-bootstrap";
|
import { Button, ButtonGroup } from "react-bootstrap";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
import cx from "classnames";
|
|
||||||
|
|
||||||
import * as GQL from "src/core/generated-graphql";
|
import * as GQL from "src/core/generated-graphql";
|
||||||
import { Icon } from "src/components/Shared/Icon";
|
import { Icon } from "src/components/Shared/Icon";
|
||||||
@@ -43,9 +42,12 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
|
|||||||
stashID.stash_id === performer.remote_site_id
|
stashID.stash_id === performer.remote_site_id
|
||||||
);
|
);
|
||||||
|
|
||||||
const [selectedPerformer, setSelectedPerformer] = useState<
|
const [selectedPerformer, setSelectedPerformer] = useState<Performer>();
|
||||||
Performer | undefined
|
|
||||||
>();
|
function selectPerformer(selected: Performer | undefined) {
|
||||||
|
setSelectedPerformer(selected);
|
||||||
|
setSelectedID(selected?.id);
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
@@ -56,18 +58,16 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
|
|||||||
}
|
}
|
||||||
}, [performerData?.findPerformer, selectedID]);
|
}, [performerData?.findPerformer, selectedID]);
|
||||||
|
|
||||||
const handlePerformerSelect = (performers: Performer[]) => {
|
const handleSelect = (performers: Performer[]) => {
|
||||||
if (performers.length) {
|
if (performers.length) {
|
||||||
setSelectedPerformer(performers[0]);
|
selectPerformer(performers[0]);
|
||||||
setSelectedID(performers[0].id);
|
|
||||||
} else {
|
} else {
|
||||||
setSelectedPerformer(undefined);
|
selectPerformer(undefined);
|
||||||
setSelectedID(undefined);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePerformerSkip = () => {
|
const handleSkip = () => {
|
||||||
setSelectedID(undefined);
|
selectPerformer(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (stashLoading) return <div>Loading performer</div>;
|
if (stashLoading) return <div>Loading performer</div>;
|
||||||
@@ -83,7 +83,7 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
|
|||||||
<OptionalField
|
<OptionalField
|
||||||
exclude={selectedID === undefined}
|
exclude={selectedID === undefined}
|
||||||
setExclude={(v) =>
|
setExclude={(v) =>
|
||||||
v ? handlePerformerSkip() : setSelectedID(matchedPerformer.id)
|
v ? handleSkip() : setSelectedID(matchedPerformer.id)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
@@ -127,16 +127,14 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant={selectedSource === "skip" ? "primary" : "secondary"}
|
variant={selectedSource === "skip" ? "primary" : "secondary"}
|
||||||
onClick={() => handlePerformerSkip()}
|
onClick={() => handleSkip()}
|
||||||
>
|
>
|
||||||
<FormattedMessage id="actions.skip" />
|
<FormattedMessage id="actions.skip" />
|
||||||
</Button>
|
</Button>
|
||||||
<PerformerSelect
|
<PerformerSelect
|
||||||
values={selectedPerformer ? [selectedPerformer] : []}
|
values={selectedPerformer ? [selectedPerformer] : []}
|
||||||
onSelect={handlePerformerSelect}
|
onSelect={handleSelect}
|
||||||
className={cx("performer-select", {
|
active={selectedSource === "existing"}
|
||||||
"performer-select-active": selectedSource === "existing",
|
|
||||||
})}
|
|
||||||
isClearable={false}
|
isClearable={false}
|
||||||
/>
|
/>
|
||||||
{maybeRenderLinkButton()}
|
{maybeRenderLinkButton()}
|
||||||
|
|||||||
@@ -66,6 +66,16 @@
|
|||||||
background-color: hsl(204, 20%, 30%);
|
background-color: hsl(204, 20%, 30%);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.performer-select,
|
||||||
|
.studio-select {
|
||||||
|
width: 14rem;
|
||||||
|
|
||||||
|
// stylelint-disable-next-line selector-class-pattern
|
||||||
|
&-active .react-select__control {
|
||||||
|
background-color: #137cbd;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.selected-result {
|
.selected-result {
|
||||||
@@ -98,16 +108,6 @@
|
|||||||
width: 2rem;
|
width: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.performer-select,
|
|
||||||
.studio-select {
|
|
||||||
width: 14rem;
|
|
||||||
|
|
||||||
// stylelint-disable-next-line selector-class-pattern
|
|
||||||
&-active .react-select__control {
|
|
||||||
background-color: #137cbd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.entity-name {
|
.entity-name {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
|||||||
Reference in New Issue
Block a user