feat: added clear btn in filter component (#6229) (#6295)

Co-authored-by: Slinetrac <realakayuki@gmail.com>
This commit is contained in:
JingxinXu 2026-02-11 14:40:47 +08:00 committed by GitHub
parent a019b26ceb
commit bba71aaa4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 52 additions and 25 deletions

View File

@ -27,6 +27,7 @@
- 避免脏订阅地址无法 Scheme 导入订阅
- macOS TUN 覆盖 DNS 时使用 114.114.114.114
- 连通性测试替换为更快的 https://1.1.1.1
- 连接、规则、日志等页面的过滤搜索组件新增了清空输入框按钮
- 链式代理增加明显的入口出口与数据流向标识
</details>

View File

@ -1,4 +1,5 @@
import { Box, SvgIcon, TextField, styled } from "@mui/material";
import { ClearRounded } from "@mui/icons-material";
import { Box, SvgIcon, TextField, styled, IconButton } from "@mui/material";
import Tooltip from "@mui/material/Tooltip";
import {
ChangeEvent,
@ -168,6 +169,11 @@ export const BaseSearchBox = ({
});
};
const handleClearInput = () => {
setText("");
emitSearch({ text: "", matchCase, matchWholeWord, useRegularExpression });
};
const handleToggleMatchCase = () => {
const next = !matchCase;
setMatchCase(next);
@ -200,35 +206,40 @@ export const BaseSearchBox = ({
sx: { pr: 1 },
endAdornment: (
<Box display="flex">
<Tooltip title={t("shared.placeholders.matchCase")}>
<div>
<SvgIcon
component={matchCaseIcon}
{!!text && (
<Tooltip title={t("shared.placeholders.resetInput")}>
<IconButton
size="small"
{...iconStyle}
aria-label={matchCase ? "active" : "inactive"}
onClick={handleToggleMatchCase}
/>
</div>
onClick={handleClearInput}
>
<ClearRounded fontSize="inherit" />
</IconButton>
</Tooltip>
)}
<Tooltip title={t("shared.placeholders.matchCase")}>
<SvgIcon
component={matchCaseIcon}
{...iconStyle}
aria-label={matchCase ? "active" : "inactive"}
onClick={handleToggleMatchCase}
/>
</Tooltip>
<Tooltip title={t("shared.placeholders.matchWholeWord")}>
<div>
<SvgIcon
component={matchWholeWordIcon}
{...iconStyle}
aria-label={matchWholeWord ? "active" : "inactive"}
onClick={handleToggleMatchWholeWord}
/>
</div>
<SvgIcon
component={matchWholeWordIcon}
{...iconStyle}
aria-label={matchWholeWord ? "active" : "inactive"}
onClick={handleToggleMatchWholeWord}
/>
</Tooltip>
<Tooltip title={t("shared.placeholders.useRegex")}>
<div>
<SvgIcon
component={UseRegularExpressionIcon}
aria-label={useRegularExpression ? "active" : "inactive"}
{...iconStyle}
onClick={handleToggleUseRegularExpression}
/>
</div>
<SvgIcon
component={UseRegularExpressionIcon}
aria-label={useRegularExpression ? "active" : "inactive"}
{...iconStyle}
onClick={handleToggleUseRegularExpression}
/>
</Tooltip>
</Box>
),

View File

@ -55,6 +55,7 @@
"files": "Files"
},
"placeholders": {
"resetInput": "مربع إدخال واضح",
"filter": "شروط التصفية",
"matchCase": "مطابقة الحالة",
"matchWholeWord": "مطابقة الكلمة بأكملها",

View File

@ -55,6 +55,7 @@
"files": "Files"
},
"placeholders": {
"resetInput": "Eingabefeld leeren",
"filter": "Filterbedingungen",
"matchCase": "Groß-/Kleinschreibung beachten",
"matchWholeWord": "Ganzes Wort übereinstimmen",

View File

@ -55,6 +55,7 @@
"files": "Files"
},
"placeholders": {
"resetInput": "Clear Input",
"filter": "Filter conditions",
"matchCase": "Match Case",
"matchWholeWord": "Match Whole Word",

View File

@ -55,6 +55,7 @@
"files": "Files"
},
"placeholders": {
"resetInput": "Borrar el cuadro de entrada",
"filter": "Condiciones de filtrado",
"matchCase": "Distinguir mayúsculas y minúsculas",
"matchWholeWord": "Coincidencia exacta de palabras",

View File

@ -55,6 +55,7 @@
"files": "Files"
},
"placeholders": {
"resetInput": "پاک کردن فیلد ورودی",
"filter": "شرایط فیلتر",
"matchCase": "تطبیق حروف کوچک و بزرگ",
"matchWholeWord": "تطبیق کل کلمه",

View File

@ -55,6 +55,7 @@
"files": "Files"
},
"placeholders": {
"resetInput": "Bersihkan kolom input",
"filter": "Kondisi Filter",
"matchCase": "Cocokkan Kasus",
"matchWholeWord": "Cocokkan Kata Utuh",

View File

@ -55,6 +55,7 @@
"files": "Files"
},
"placeholders": {
"resetInput": "入力フィールドをクリア",
"filter": "フィルタリング条件",
"matchCase": "大文字小文字を区別する",
"matchWholeWord": "完全一致",

View File

@ -55,6 +55,7 @@
"files": "파일"
},
"placeholders": {
"resetInput": "입력 필드 지우기",
"filter": "필터 조건",
"matchCase": "대/소문자 구분",
"matchWholeWord": "단어 전체 일치",

View File

@ -55,6 +55,7 @@
"files": "Files"
},
"placeholders": {
"resetInput": "Очистить поле ввода",
"filter": "Условия фильтрации",
"matchCase": "Учитывать регистр",
"matchWholeWord": "Полное совпадение слова",

View File

@ -55,6 +55,7 @@
"files": "Files"
},
"placeholders": {
"resetInput": "Giriş alanını temizle",
"filter": "Filtre koşulları",
"matchCase": "Büyük/Küçük Harf Eşleştir",
"matchWholeWord": "Tam Kelime Eşleştir",

View File

@ -55,6 +55,7 @@
"files": "Files"
},
"placeholders": {
"resetInput": "кертү кырын чистарту",
"filter": "Фильтр шартлары",
"matchCase": "Регистрны исәпкә алу",
"matchWholeWord": "Сүзнең тулы туры килүе",

View File

@ -55,6 +55,7 @@
"files": "文件"
},
"placeholders": {
"resetInput": "清空输入框",
"filter": "过滤条件",
"matchCase": "区分大小写",
"matchWholeWord": "全字匹配",

View File

@ -55,6 +55,7 @@
"files": "檔案"
},
"placeholders": {
"resetInput": "清空輸入框",
"filter": "篩選條件",
"matchCase": "區分大小寫",
"matchWholeWord": "完整字詞配對",

View File

@ -730,6 +730,7 @@ export const translationKeys = [
"shared.units.hours",
"shared.units.kilobytes",
"shared.units.files",
"shared.placeholders.resetInput",
"shared.placeholders.filter",
"shared.placeholders.matchCase",
"shared.placeholders.matchWholeWord",

View File

@ -1318,6 +1318,7 @@ export interface TranslationResources {
usedTotal: string;
};
placeholders: {
resetInput: string;
filter: string;
matchCase: string;
matchWholeWord: string;