Skip to content

[Tree] Add a clear (X) button to the element tree search - #4249

Open
sholzer wants to merge 2 commits into
2026.xfrom
claude/issue-3759-tree-search-clear
Open

sholzer wants to merge 2 commits into
2026.xfrom
claude/issue-3759-tree-search-clear

Conversation

@sholzer

@sholzer sholzer commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Changes in this pull request

Resolves #3759

The search field in the asset, data-object and document trees had no clear (X) button: to reset a search, the text had to be deleted by hand and submitted again.

All three trees use the shared ElementTreeSearchContainer, which rendered antd Input.Search without allowClear. It now has allowClear with Studio's close icon, as SearchInput and the user tree autocomplete already do. In antd 5.22 a click on the X calls onSearch(''), which goes through the existing handler unchanged: the search term is reset and the pager goes back to page 1, exactly like an empty submit.

For reviewers to weigh:

  • ElementTreeSearchContainer is exported in the SDK, so plugin trees that render it also get the X, with no prop to switch it off. Additive; no signature change.
  • The tree search takes only the close-icon style from search-input.styles, not its full search style, so a later style change in SearchInput does not reach the tree search.

Additional info

Tests

  • search-container.test.tsx (new): the X appears once there is text; clicking it clears the field and resets the search like an empty submit (term undefined, page 1). Both fail without the change.

Verified

  • check-types, lint, npm test (1929 tests) and build-app pass.
  • In a browser against a demo instance, with this branch's build served and writes blocked: in the Data Objects tree (a folder with more children than the page size) the empty field shows no X, typing shows it, Enter filters, and the X clears the field and shows the full list from page 1. The X is Studio's close icon and sits vertically centred.

Not verified

  • Assets and Documents with their real page sizes: the demo has no folder large enough to show the search field there. The same steps passed with the page size lowered in the test browser only.

The build output is not part of this PR.

🤖 Generated with Claude Code

sholzer and others added 2 commits October 22, 2026 14:55
The asset, data-object and document tree search now offers antd's allowClear with Studio's close icon. Clearing calls onSearch('') and resets the search term and page like an empty submit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drops the import/first eslint-disable comments the Sonar pre-check reports; jest.mock is hoisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@sholzer
sholzer marked this pull request as ready for review October 22, 2026 14:04
Copilot AI balanced review requested due to automatic review settings October 22, 2026 14:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrowly scoped shared-component change addresses the missing control with focused regression coverage and no unresolved blocking findings.

No open issues 🎉

What changed in this PR

Verdict: LGTM. This PR addresses #3759 by adding a clear (X) button to the shared element-tree search used by assets, data objects, documents, and SDK consumers.

Changes:

  • Enables Ant Design’s allowClear with Studio’s close icon (search-container.tsx:44–51), fixing the missing control in the owning component rather than individual tree consumers.
  • Reuses the close-icon styling without changing the component’s public signature. All consumers receive the additive clear control.
  • Adds focused regression tests for clear-button visibility and clearing the field while resetting the search term and page (search-container.test.tsx:61–83).

Coverage and remaining risks: The shared implementation covers all three tree types without caller-specific changes. No documentation or changelog files were changed. Tests were not rerun during this review; the PR reports successful checks, but browser verification for Assets and Documents used reduced page sizes rather than their real defaults.

File Description
assets/​js/​src/​core/​components/​element-tree/​search/​search-container.tsx Adds the shared clear control and Studio close-icon styling.
assets/​js/​src/​core/​components/​element-tree/​search/​search-container.test.tsx Tests control visibility, field clearing, and search/pagination reset.

Review effort: Balanced

@sholzer sholzer added this to the 2026.4.0 milestone Oct 22, 2026
@sholzer
sholzer requested a review from vin0401 October 22, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search in Studio UI tree view lacks "clear" option

2 participants