mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Fix buttons not working correct in number filter (#3177)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useRef } from "react";
|
||||
import React from "react";
|
||||
import { Form } from "react-bootstrap";
|
||||
import { useIntl } from "react-intl";
|
||||
import { CriterionModifier } from "../../../core/generated-graphql";
|
||||
@@ -16,18 +16,15 @@ export const NumberFilter: React.FC<IDurationFilterProps> = ({
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
|
||||
const valueStage = useRef<INumberValue>(criterion.value);
|
||||
|
||||
function onChanged(
|
||||
event: React.ChangeEvent<HTMLInputElement>,
|
||||
property: "value" | "value2"
|
||||
) {
|
||||
const value = parseInt(event.target.value, 10);
|
||||
valueStage.current[property] = !Number.isNaN(value) ? value : 0;
|
||||
}
|
||||
const numericValue = parseInt(event.target.value, 10);
|
||||
const valueCopy = { ...criterion.value };
|
||||
|
||||
function onBlurInput() {
|
||||
onValueChanged(valueStage.current);
|
||||
valueCopy[property] = !Number.isNaN(numericValue) ? numericValue : 0;
|
||||
onValueChanged(valueCopy);
|
||||
}
|
||||
|
||||
let equalsControl: JSX.Element | null = null;
|
||||
@@ -43,8 +40,7 @@ export const NumberFilter: React.FC<IDurationFilterProps> = ({
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
|
||||
onChanged(e, "value")
|
||||
}
|
||||
onBlur={onBlurInput}
|
||||
defaultValue={criterion.value?.value ?? ""}
|
||||
value={criterion.value?.value ?? ""}
|
||||
placeholder={intl.formatMessage({ id: "criterion.value" })}
|
||||
/>
|
||||
</Form.Group>
|
||||
@@ -65,8 +61,7 @@ export const NumberFilter: React.FC<IDurationFilterProps> = ({
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
|
||||
onChanged(e, "value")
|
||||
}
|
||||
onBlur={onBlurInput}
|
||||
defaultValue={criterion.value?.value ?? ""}
|
||||
value={criterion.value?.value ?? ""}
|
||||
placeholder={intl.formatMessage({ id: "criterion.greater_than" })}
|
||||
/>
|
||||
</Form.Group>
|
||||
@@ -92,8 +87,7 @@ export const NumberFilter: React.FC<IDurationFilterProps> = ({
|
||||
: "value2"
|
||||
)
|
||||
}
|
||||
onBlur={onBlurInput}
|
||||
defaultValue={
|
||||
value={
|
||||
(criterion.modifier === CriterionModifier.LessThan
|
||||
? criterion.value?.value
|
||||
: criterion.value?.value2) ?? ""
|
||||
|
||||
Reference in New Issue
Block a user