Repository navigation
fix: mk table filter support to search #7882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,7 +156,14 @@ onMounted(() => { | |
| </el-table-column> | ||
| <el-table-column v-if="auth.isEE" prop="workspace_name" min-width="160" show-overflow-tooltip> | ||
| <template #header> | ||
| <MkTableFilter mode="multiple" v-model="selectedWorkspaceIds" label="工作空间" :options="workspaceOptions" @change="handleFilterChange" /> | ||
| <MkTableFilter | ||
| mode="multiple" | ||
| v-model="selectedWorkspaceIds" | ||
| label="工作空间" | ||
| filterable | ||
| :options="workspaceOptions" | ||
| @change="handleFilterChange" | ||
| /> | ||
| </template> | ||
| </el-table-column> | ||
| <el-table-column prop="nick_name" label="创建者" min-width="120" show-overflow-tooltip /> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Summary of the change Potential issues / things to verify
Minor style/nit
Overall: No irregularities in syntax. The main risk is whether |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,7 +162,14 @@ onMounted(() => { | |
| </el-table-column> | ||
| <el-table-column v-if="auth.isEE" prop="workspace_name" min-width="160" show-overflow-tooltip> | ||
| <template #header> | ||
| <MkTableFilter mode="multiple" v-model="selectedWorkspaceIds" label="工作空间" :options="workspaceOptions" @change="handleFilterChange" /> | ||
| <MkTableFilter | ||
| mode="multiple" | ||
| v-model="selectedWorkspaceIds" | ||
| label="工作空间" | ||
| filterable | ||
| :options="workspaceOptions" | ||
| @change="handleFilterChange" | ||
| /> | ||
| </template> | ||
| </el-table-column> | ||
| <el-table-column prop="nick_name" label="创建者" min-width="120" show-overflow-tooltip /> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change itself is minor (just adding a Potential issues
Optimization suggestions
Minor style
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issues Found
1. Semantics of "Select All" under search are ambiguous / possibly buggy
In
handleSelectAllChange, whenfilterableis true, the retained values are computed as:This works for retaining hidden selections — but there's a subtle issue: when
checkedisfalse, this keeps all values not in the filtered set, which is correct. However, the "全部" checkbox itself toggles based on filtered options only. That behavior is fine semantically, but should be documented — users may expect "select all" to mean "all options", not "all visible options". Consider renaming or adding a tooltip.2. Indeterminate state ignores hidden selections
selectionIndeterminateandallSelectedare both computed fromallOptionValues(filtered). If a user searches, selects some items, then changes the search, the state of "全部" reflects only the current filter. This is likely intended but can confuse users — make sure it's documented.3.
disabledcheckbox in "全部" uses inconsistent logicWhen
filterableisfalse, this is never disabled — even if there are no options at all. The original code had no disable guard. Consider making it consistent::disabled="!allOptionValues.length"regardless offilterable.4. Search input placement renders outside the scrollbar → layout jump
The
MkSearchInputis placed aboveel-scrollbar, so it won't scroll with content. That's usually desirable, but make suremax-height="280px"on the scrollbar doesn't cause the popover to grow oddly. Also, the empty-state (MkEmpty) lives inside the scroll area while the checkbox for "全部" stays visible — verify that looks acceptable when there are 0 filtered results.5. Missing whitespace-trimmed keyword state reset timing
searchKeyword.value = ''is reset inhandleOpen, which fires on@before-enter. This means during the close animation the previous keyword is still shown briefly, which is fine. But if a user reopens quickly,before-entermay not fire. Prefer explicitly resetting in a watcher onvisible:6.
Setspread loses order = OK but could surprise[...new Set([...retainedValues, ...allOptionValues.value])]preserves insertion order — good. But note thatretainedValuescomes first, so the resulting order differs fromprops.optionsordering. If consumers depend on order, sort byprops.optionsindex instead. Minor.7. Case sensitivity only lowercases
label, not non-string labelsAssumes
labelis always a string. IfTableFilterOption.labelcan benumber/VNode, this will throw. Guard it or type it asstring.8. Performance: filtering +
includesinsideevery/someis O(n·m)For large option lists this is
O(n²)per computed run. Consider using aSetofpendingValuesinside those computeds:Then use
.has(value).9. Duplicated key generation
key={${typeof option.value}:${option.value}}is repeated in two places — extract to a helper function for readability.10. No debounce on search
If
optionsis very large, filtering on each keystroke and re-rendering thousands of checkboxes will lag. Consider debouncingsearchKeyword(e.g., 150–200ms) or virtualizing the list.11. Accessibility
MkSearchInputshould have anaria-label(e.g., "Search options").MkEmptyinside a role group is fine, but ensure the checkbox group remains correctly labeled after the empty state appears.Summary of recommended fixes (priority order)
option.labeltyping for.toLowerCase().SetforpendingValueslookups in computeds.searchKeywordvia a watch onvisiblerather thanbefore-enter.disabledlogic on the "全部" checkbox.aria-labelto search.