Fix: Preserve multiple consecutive spaces in Theia UI elements#16935
Conversation
|
Hi @awaisahmed119, thank you for your contribution to Theia! Before we can proceed, could you please sign the Eclipse Contributor Agreement (ECA). This is a one-time requirement for contributing to Eclipse Foundation projects. To sign the ECA:
After signing, we can retrigger the ECA check and it should pass automatically and we can run the remaining workflows too. |
9ccf5d6 to
bbccbc1
Compare
Done |
|
should we be setting white-space-collapse instead? white-space changes other behaviors as well other than collapsing spaces, right? |
The white-space-collapse property is newer (CSS Text Level 4) and has limited browser support, making it unsuitable for production use. While white-space does control multiple behaviors (space collapsing, wrapping, and line breaks), you actually need that combined control for this use case. Using white-space: pre gives you both space preservation and no-wrap behavior for tree nodes, while white-space: pre-wrap provides space preservation with wrapping for tooltips. If you used white-space-collapse, you'd need multiple separate properties to achieve the same result with worse browser compatibility. The white-space property seems the correct, widely-supported solution here. |
Fixed. Please have a look. |
d021cbf to
0f5b460
Compare
Fixes: eclipse-theia#16865 PROBLEM: - Multiple consecutive spaces in file/folder names were collapsed to single space - HTML whitespace normalization and textContent API both collapse spaces CSS CHANGES: - tree.css: Applied white-space: pre to .theia-TreeNodeSegment and .theia-TreeNodeSegmentGrow - dialog.css: Applied white-space: pre-wrap to dialog content (li, div) - tabs.css: Applied white-space: pre-wrap to tab hover title and caption - tooltip.css: Applied white-space: pre-wrap to .theia-tooltip - breadcrumbs.css: Applied white-space: pre-wrap to breadcrumb labels - tree-decorators.css: Applied white-space: pre to decorator badges JAVASCRIPT CHANGE: - tab-bars.ts (handleMouseEnterEvent): Replace consecutive spaces with non-breaking spaces (\u00A0) before passing to hover service RATIONALE: - CSS white-space: pre/pre-wrap handles directly rendered HTML elements - JavaScript solution needed for tooltips because hover-service.ts uses textContent which normalizes whitespace BEFORE CSS is applied - Non-breaking spaces (\u00A0) are not collapsed by textContent API - Used 'pre' for short content (tree nodes, badges) to prevent wrapping - Used 'pre-wrap' for long content (tooltips, dialogs, paths) to allow wrapping Fix: Fixed linting issues.
0f5b460 to
c55f16f
Compare
ndoschek
left a comment
There was a problem hiding this comment.
Thanks a lot for the updates!
This works great, thanks again for this improvement! 🎉
What it does
Fixes multiple consecutive spaces being collapsed to single space in Theia UI elements (explorer tree, dialogs, breadcrumbs, and editor tab tooltips).
How to test
"test file.txt","folder name")Follow-ups
Breaking changes
Attribution
Review checklist
nlsservice (for details, please see the Internationalization/Localization section in the Coding Guidelines)Reminder for reviewers