Skip to content

Show filter hint only as placeholder in filtered viewers#4074

Open
vogella wants to merge 2 commits into
eclipse-platform:masterfrom
vogella:filteredtree-no-initial-text
Open

Show filter hint only as placeholder in filtered viewers#4074
vogella wants to merge 2 commits into
eclipse-platform:masterfrom
vogella:filteredtree-no-initial-text

Conversation

@vogella

@vogella vogella commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Filtered viewers used to write the hint text ("type filter text") into the filter field's value when the field had focus, which required clear-on-focus handling and could be read by screen readers as an actual filter value. This moves the shared AbstractFilteredViewerComposite#setInitialText to expose the hint solely as the field's placeholder via Text#setMessage.

Showing a hint inside the field value is a recognized UX anti-pattern (see https://www.nngroup.com/articles/form-design-placeholders/). The placeholder gives the same visible hint without those drawbacks, and the accessible name is unaffected.

The fix lives in the JFace base, so it applies to FilteredTree, the e4 FilteredTree and FilteredTable at once, aligning them with the approach already used by FilteredPreferenceDialog and ChooseWorkspaceDialog.

@vogella vogella requested a review from HeikoKlare June 9, 2026 13:12
@vogella vogella force-pushed the filteredtree-no-initial-text branch from 3908dc3 to 46ae2b3 Compare June 9, 2026 13:14
@vogella

vogella commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

One thing I deliberately left alone: a few now-unreachable branches that compared the field value to initialText (the focusLost/mouseDown/focusGained handlers in this base, and the initial/narrowingDown checks in both FilteredTree copies). They're harmless dead branches now.

I kept the diff minimal rather than ripping them out, can be done as follow-up clean-up if that change is accepted.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Test Results

   861 files  ±0     861 suites  ±0   51m 26s ⏱️ - 4m 27s
 8 034 tests ±0   7 791 ✅ ±0  243 💤 ±0  0 ❌ ±0 
20 541 runs  ±0  19 886 ✅ ±0  655 💤 ±0  0 ❌ ±0 

Results for commit 02e89b3. ± Comparison against base commit 69d1f6a.

♻️ This comment has been updated with latest results.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates JFace’s AbstractFilteredViewerComposite#setInitialText so filtered viewers show the filter hint via Text#setMessage (placeholder) rather than writing the hint into the field’s actual value, improving UX/accessibility and removing the need for hint-as-value behavior.

Changes:

  • Reworks setInitialText(String) to set the filter field’s placeholder message instead of setting the field text.
  • Updates the setInitialText Javadoc to reflect placeholder semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vogella vogella force-pushed the filteredtree-no-initial-text branch from 46ae2b3 to 746950a Compare June 9, 2026 15:02

@HeikoKlare HeikoKlare 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.

In general, the change looks sounds to me. The method is used for providing the message to the filter input, for which it makes sense to not show the message as initial text input as well (as also done in #4044).

I have two remarks (even though I don't think we can do anything reasonable about that):

  • The method is now quite misleading, as it is about setting the message and not about setting an initial text at all. This is an existing flaw (the method has the message in addition to the initial text before as well, without this really making sense), which becomes slightly more severe with this change.
  • textChanged() was always implicitly called when initializing an AbstractFilteredViewerComposite before this change. Consumers might rely on this behavior and break now.

I understand that it makes sense to keep this PR free from follow-up cleanups. What I would still propose it to clean up this code, as it will be hard to find that this change has affected it:

|| previousFilterText.equals(WorkbenchMessages.FilteredTree_FilterMessage)

Since FilteredTree_FilterMessage is not set as text input anywhere anymore (except for if a user accidentally inputs exactly that string), this check should be removed here, as it is tighly coupled to this value being set via setInitialText.

@vogella

vogella commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

IIRC we have the same in the e4 FilteredTree so the diff will become a little bit bigger.

Will update this as soon as I find time....

AbstractFilteredViewerComposite#setInitialText wrote the hint into the
filter field value when the field had focus, which required clear-on-focus
handling and could be misread by screen readers as an actual filter value.
Expose the hint solely via Text#setMessage instead.

This aligns FilteredTree, the e4 FilteredTree and FilteredTable with the
approach already used by FilteredPreferenceDialog and ChooseWorkspaceDialog.
@vogella vogella force-pushed the filteredtree-no-initial-text branch from 746950a to 5ee0060 Compare June 9, 2026 17:34
@vogella

vogella commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Good point, done. Removed the now-dead previousFilterText.equals(FilteredTree_FilterMessage) branch from textChanged() in both the workbench and the e4 FilteredTree, since that string is no longer written into the field value.

@eclipse-platform-bot

Copy link
Copy Markdown
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

bundles/org.eclipse.e4.ui.dialogs/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From a2fd6b5a1dc16e3989710e16aad6932f54ea199d Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Tue, 9 Jun 2026 17:37:31 +0000
Subject: [PATCH] Version bump(s) for 4.41 stream


diff --git a/bundles/org.eclipse.e4.ui.dialogs/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.dialogs/META-INF/MANIFEST.MF
index 611cc9ab0a..1391e40656 100644
--- a/bundles/org.eclipse.e4.ui.dialogs/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.ui.dialogs/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.e4.ui.dialogs
-Bundle-Version: 1.7.100.qualifier
+Bundle-Version: 1.7.200.qualifier
 Bundle-RequiredExecutionEnvironment: JavaSE-21
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
-- 
2.54.0

Further information are available in Common Build Issues - Missing version increments.

@vogella

vogella commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

@HeikoKlare is this fine for you?

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.

4 participants