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 导入订阅 - 避免脏订阅地址无法 Scheme 导入订阅
- macOS TUN 覆盖 DNS 时使用 114.114.114.114 - macOS TUN 覆盖 DNS 时使用 114.114.114.114
- 连通性测试替换为更快的 https://1.1.1.1 - 连通性测试替换为更快的 https://1.1.1.1
- 连接、规则、日志等页面的过滤搜索组件新增了清空输入框按钮
- 链式代理增加明显的入口出口与数据流向标识 - 链式代理增加明显的入口出口与数据流向标识
</details> </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 Tooltip from "@mui/material/Tooltip";
import { import {
ChangeEvent, ChangeEvent,
@ -168,6 +169,11 @@ export const BaseSearchBox = ({
}); });
}; };
const handleClearInput = () => {
setText("");
emitSearch({ text: "", matchCase, matchWholeWord, useRegularExpression });
};
const handleToggleMatchCase = () => { const handleToggleMatchCase = () => {
const next = !matchCase; const next = !matchCase;
setMatchCase(next); setMatchCase(next);
@ -200,35 +206,40 @@ export const BaseSearchBox = ({
sx: { pr: 1 }, sx: { pr: 1 },
endAdornment: ( endAdornment: (
<Box display="flex"> <Box display="flex">
<Tooltip title={t("shared.placeholders.matchCase")}> {!!text && (
<div> <Tooltip title={t("shared.placeholders.resetInput")}>
<SvgIcon <IconButton
component={matchCaseIcon} size="small"
{...iconStyle} {...iconStyle}
aria-label={matchCase ? "active" : "inactive"} onClick={handleClearInput}
onClick={handleToggleMatchCase} >
/> <ClearRounded fontSize="inherit" />
</div> </IconButton>
</Tooltip>
)}
<Tooltip title={t("shared.placeholders.matchCase")}>
<SvgIcon
component={matchCaseIcon}
{...iconStyle}
aria-label={matchCase ? "active" : "inactive"}
onClick={handleToggleMatchCase}
/>
</Tooltip> </Tooltip>
<Tooltip title={t("shared.placeholders.matchWholeWord")}> <Tooltip title={t("shared.placeholders.matchWholeWord")}>
<div> <SvgIcon
<SvgIcon component={matchWholeWordIcon}
component={matchWholeWordIcon} {...iconStyle}
{...iconStyle} aria-label={matchWholeWord ? "active" : "inactive"}
aria-label={matchWholeWord ? "active" : "inactive"} onClick={handleToggleMatchWholeWord}
onClick={handleToggleMatchWholeWord} />
/>
</div>
</Tooltip> </Tooltip>
<Tooltip title={t("shared.placeholders.useRegex")}> <Tooltip title={t("shared.placeholders.useRegex")}>
<div> <SvgIcon
<SvgIcon component={UseRegularExpressionIcon}
component={UseRegularExpressionIcon} aria-label={useRegularExpression ? "active" : "inactive"}
aria-label={useRegularExpression ? "active" : "inactive"} {...iconStyle}
{...iconStyle} onClick={handleToggleUseRegularExpression}
onClick={handleToggleUseRegularExpression} />
/>
</div>
</Tooltip> </Tooltip>
</Box> </Box>
), ),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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