Make tags that scroll out of view reachable in the tag field #514
Test Results
141 files ±0 141 suites ±0 3m 9s ⏱️ -11s
919 tests ±0 919 ✅ ±0 0 💤 ±0 0 ❌ ±0
1 051 runs ±0 1 045 ✅ ±0 6 💤 ±0 0 ❌ ±0
Results for commit 911c0bcd. ± Comparison against base commit 0638c21b.
[test-results]:data:application/gzip;base64,H4sIAFF76moC/13NTQ6DIBCG4asY1l3MKBDoZRoZICH1p0FYmd69aJXYLt9nkm9W5sPgFnZvkOOtYUsO6ZI2xz6FedpA6QLlmLazxlqPJRP90zO8CkEF34fhB1yMczwk5ml/CQKPOjcRuKj03ZRnXyb3vi7SPI4hlWAakcCQVS10rpWKg1CdtC1Z3nvU3AiwWhpi7w9NB3ILCwEAAA==
:recycle: This comment has been updated with latest results.
Bugs:
1. Typed text carries over to the next channel. Text typed but not committed stays in the editor, still in edit mode, when you open another channel: editChannel → setChannelTags never clears it. Saving the second channel then adds that text as a tag via createTagOnFocusLost.
2. Editor stuck between chips. If you type between two chips and click Save, the tag is added but the editor stays where it was, empty and unfocused, with no prompt.
Lower priority:
getPreferredSize reaches the editor through the outer editor field, which is still null while the text field is being built. It's a possible null pointer error if the size is ever asked for that early.
editorIndex is reset by hand before setTokens in three places, but update() and clear() don't do it. One reset inside setTokens would cover all of them.
moveEditor rebuilds every chip on each arrow-key press. setComponentZOrder would move the editor and keep focus.
MetalLookAndFeel rather than UIManager.Looks safe to merge.
[!NOTE]
I marked as draft because I pushed each point as a separate fixup! commit so that the individual fixes were easy to make out from the previous code. I wanted to make sure those commits were autosquashed after review and before merging, but I don't plan on making any more changes.
@NicoPiel Thanks for the careful look. All of these are addressed in the latest push, either with a fix or an explanation below.
Bugs:
1. Typed text carries over to the next channel. Fixed: setChannelTags now clears the editor and leaves edit mode. The text already carried over before this PR, but edit mode made it much easier to notice.
2. Editor stuck between chips. Fixed: when createTagOnFocusLost commits while the editor doesn't have focus, as with Save, it moves the editor back to the end, where the prompt shows again. If you save with Ctrl+S while still typing, the editor keeps focus and stays where it is.
Lower priority:
getPreferredSize before editor is set. Fixed: isShowingPrompt() treats a null editor as unfocused.
editorIndex in setTokens. I left this one as is, on purpose. The three places that reset it by hand load a different set of tags, so the editor goes to the end. update() re-resolves the same tags on every Dashboard refresh. Resetting there would pull the editor back to the end every few seconds while someone is moving it or typing. clear() empties the tags, so the clamp in setTokens already puts the editor at 0, which is the end.
moveEditor rebuilding every chip. Done: it now moves the editor with setComponentZOrder and leaves the chips alone.
Frame.setCurrentContentPage removes the previous page from the viewport, and removeNotify takes that field's listener with it. The listener checks only the event ID and button before returning, so the cost per mouse event is negligible.
MetalLookAndFeel. Done: the outline reads UIManager.getColor("Button.focus") each time it paints, so it follows the look and feel. Under the client's Plastic theme, it's the same color as before.
---
_Drafted with Claude Code_
Approved these changes.
NicoPiel
tonygermano
Summary
Follow-up to #437. When a tag field has more tags than fit, the first ones scroll past the left edge, and there was no way to get back to them (see @NicoPiel's review). In the channel editor, which has no clear button, the only way to remove the first tag was to backspace through every tag after it.
This PR makes every tag reachable from both the mouse and the keyboard, and removes a license notice #437 left behind. It applies to all three tag fields: the channel editor and the Dashboard and Channels filters.
Changes
Keyboard navigation with an edit mode. The text editor can now sit between chips, and new tags are inserted where it is. Typing enters an edit mode, shown by an outline around the text, and the keys behave differently in each mode:
| Key | Navigating | Edit mode |
|-|-|-|
| Left / Right | Move the editor past a chip | Move the caret |
| Home / End | Move the editor to the first or last slot | Move the caret |
| Backspace / Delete | Remove the chip before or after the editor | Edit the text |
| Enter / comma | Nothing | Commit the text |
| Escape | Passed on to the window | Clear the text and leave edit mode without committing |
Edit mode lasts until the text is committed, Escape is pressed, or the field loses focus with no text. Deleting the text doesn't end it, so holding Backspace to clear what you typed can't run on into the chips.
Mouse wheel scrolling. The wheel and sideways trackpad swipes scroll the chips. When all the chips fit, the wheel event is passed on, so an enclosing scroll pane still scrolls. Before, the field swallowed it.
Mouse deletion and placement.
Third-party notice. #437 removed the last bundled copy of bootstrap-tokenfield, so its section of
THIRD-PARTY-README.txtis removed. The jQuery and Bootstrap sections stay, sinceserver/public_api_htmlstill ships both.Commits
Each commit builds on its own.
1. Navigate tag chips from the keyboard with an edit mode. The editor sits between chips, edit mode works as described above, and the editor is sized to its text. The editor and its outline use
TagChip's font and corner radius, so typed text looks like the chips.2. Drop the bootstrap-tokenfield third-party notice.
3. Scroll the tag chips with the mouse wheel. This includes sideways scrolling on Linux. X11 reports it as mouse buttons 4 and 5 rather than as wheel events, so it needs its own listener.
4. Delete tag chips with a middle click and place the editor by clicking.
Testing
./gradlew clean buildpasses.---
_Drafted with Claude Code_