mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Add clear button to list filter search input (#1845)
* add clear button to list filter search input
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
* Added interface options to disable creating performers/studios/tags from dropdown selectors. ([#1814](https://github.com/stashapp/stash/pull/1814))
|
* Added interface options to disable creating performers/studios/tags from dropdown selectors. ([#1814](https://github.com/stashapp/stash/pull/1814))
|
||||||
|
|
||||||
### 🎨 Improvements
|
### 🎨 Improvements
|
||||||
|
* Added clear button to query text field. ([#1845](https://github.com/stashapp/stash/pull/1845))
|
||||||
* Moved Performer rating stars from details/edit tabs to heading section of performer page. ([#1844](https://github.com/stashapp/stash/pull/1844))
|
* Moved Performer rating stars from details/edit tabs to heading section of performer page. ([#1844](https://github.com/stashapp/stash/pull/1844))
|
||||||
* Optimised scanning process. ([#1816](https://github.com/stashapp/stash/pull/1816))
|
* Optimised scanning process. ([#1816](https://github.com/stashapp/stash/pull/1816))
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import _, { debounce } from "lodash";
|
import _, { debounce } from "lodash";
|
||||||
import React, { HTMLAttributes, useEffect, useRef, useState } from "react";
|
import React, { HTMLAttributes, useEffect, useRef, useState } from "react";
|
||||||
|
import cx from "classnames";
|
||||||
import Mousetrap from "mousetrap";
|
import Mousetrap from "mousetrap";
|
||||||
import { SortDirectionEnum } from "src/core/generated-graphql";
|
import { SortDirectionEnum } from "src/core/generated-graphql";
|
||||||
import {
|
import {
|
||||||
@@ -44,6 +45,9 @@ export const ListFilter: React.FC<IListFilterProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [customPageSizeShowing, setCustomPageSizeShowing] = useState(false);
|
const [customPageSizeShowing, setCustomPageSizeShowing] = useState(false);
|
||||||
const [queryRef, setQueryFocus] = useFocus();
|
const [queryRef, setQueryFocus] = useFocus();
|
||||||
|
const [queryClearShowing, setQueryClearShowing] = useState(
|
||||||
|
!!filter.searchTerm
|
||||||
|
);
|
||||||
const perPageSelect = useRef(null);
|
const perPageSelect = useRef(null);
|
||||||
const [perPageInput, perPageFocus] = useFocus();
|
const [perPageInput, perPageFocus] = useFocus();
|
||||||
|
|
||||||
@@ -99,6 +103,14 @@ export const ListFilter: React.FC<IListFilterProps> = ({
|
|||||||
|
|
||||||
function onChangeQuery(event: React.FormEvent<HTMLInputElement>) {
|
function onChangeQuery(event: React.FormEvent<HTMLInputElement>) {
|
||||||
searchCallback(event.currentTarget.value);
|
searchCallback(event.currentTarget.value);
|
||||||
|
setQueryClearShowing(!!event.currentTarget.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onClearQuery() {
|
||||||
|
queryRef.current.value = "";
|
||||||
|
searchCallback("");
|
||||||
|
setQueryFocus();
|
||||||
|
setQueryClearShowing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChangeSortDirection() {
|
function onChangeSortDirection() {
|
||||||
@@ -217,7 +229,17 @@ export const ListFilter: React.FC<IListFilterProps> = ({
|
|||||||
onInput={onChangeQuery}
|
onInput={onChangeQuery}
|
||||||
className="query-text-field bg-secondary text-white border-secondary"
|
className="query-text-field bg-secondary text-white border-secondary"
|
||||||
/>
|
/>
|
||||||
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
onClick={onClearQuery}
|
||||||
|
title={intl.formatMessage({ id: "actions.clear" })}
|
||||||
|
className={cx(
|
||||||
|
"query-text-field-clear",
|
||||||
|
queryClearShowing ? "" : "d-none"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Icon icon="times" />
|
||||||
|
</Button>
|
||||||
<InputGroup.Append>
|
<InputGroup.Append>
|
||||||
<OverlayTrigger
|
<OverlayTrigger
|
||||||
placement="top"
|
placement="top"
|
||||||
|
|||||||
@@ -30,6 +30,27 @@ input[type="range"].zoom-slider {
|
|||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.query-text-field-clear {
|
||||||
|
background-color: $secondary;
|
||||||
|
color: $text-muted;
|
||||||
|
font-size: $btn-font-size-sm;
|
||||||
|
margin: $btn-padding-y $btn-padding-x;
|
||||||
|
padding: 0;
|
||||||
|
position: absolute;
|
||||||
|
right: 3em;
|
||||||
|
z-index: 4;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus,
|
||||||
|
&:active,
|
||||||
|
&:not(:disabled):not(.disabled):active,
|
||||||
|
&:not(:disabled):not(.disabled):active:focus {
|
||||||
|
background-color: $secondary;
|
||||||
|
border-color: transparent;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.saved-filter-list-menu {
|
.saved-filter-list-menu {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"backup": "Backup",
|
"backup": "Backup",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"clean": "Clean",
|
"clean": "Clean",
|
||||||
|
"clear": "Clear",
|
||||||
"clear_back_image": "Clear back image",
|
"clear_back_image": "Clear back image",
|
||||||
"clear_front_image": "Clear front image",
|
"clear_front_image": "Clear front image",
|
||||||
"clear_image": "Clear Image",
|
"clear_image": "Clear Image",
|
||||||
|
|||||||
Reference in New Issue
Block a user