Skip to content

color picker: remove recent colors with a hover button, delete or backspace - #3764

Open
Mario-Mohar wants to merge 2 commits into
AvengeMedia:masterfrom
Mario-Mohar:feat/remove-recent-colors
Open

Mario-Mohar wants to merge 2 commits into
AvengeMedia:masterfrom
Mario-Mohar:feat/remove-recent-colors

Conversation

@Mario-Mohar

@Mario-Mohar Mario-Mohar commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Description

Recent colors in the color picker could only be added, never removed. A wrong pick stayed in the list until five newer colors pushed it out.

Hovering a recent color swatch now shows a small close button in its corner that removes the color. With keyboard focus on a swatch, Delete or Backspace does the same. The removal goes through a new SessionData.removeRecentColor(), which filters the color out and saves the session, so it stays gone after a restart. Removing a color that is not in the list does nothing and does not write the file.

ColorPickerModal.selectedColor follows recentColors[0], and its change handler used to push every change into the editor. Removing the first recent color while the picker was open therefore replaced the color being edited. The handler now only applies changes while the picker is closed. show() still applies selectedColor on open, so callers that set it before opening are unaffected.

Tests in quickshell/tests/session-recent-colors.test.mjs cover removing and saving, the no-op for an unknown color, and adding a removed color again (it comes back first). They fail on master and pass with this change.

Tested in a nested Hyprland session with session.json seeded with a few colors:

  • Hover shows the close button, clicking it removes the color.
  • Delete and Backspace on a focused swatch remove it, and session.json is updated.
  • Removing the first color while editing: without the modal change the editor jumped from #e53935 to the next recent color #43a047, with it the edited color stays.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Refactor / internal cleanup
  • Documentation
  • Other

Related issues

Closes #3760

Screenshots / video

Removing the first recent color with Backspace while the picker is open (top: focused, bottom: after removal):

without the modal change with it
before after

Checklist

  • My code follows the conventions in CONTRIBUTING.md
  • I have tested my changes locally
  • New user-facing strings are wrapped in I18n.tr() with translator context, reusing existing terms where possible
  • Go changes: ran make fmt, added/updated tests, make test passes, and go mod tidy is clean (no Go changes)
  • QML changes: ran make lint-qml with no new warnings
  • I have opened a corresponding pull request in dlx-docs to document any new behaviors: https://github.com/AvengeMedia/DankLinux-Docs (not yet, will do once the interaction is settled)

@purian23

Copy link
Copy Markdown
Collaborator

/claude review

const recent = recentColors.filter(c => c !== colorStr);
if (recent.length === recentColors.length)
return;
recentColors = recent;

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.

Removing the first recent color while the picker is open resets the color being edited. ColorPickerModal.selectedColor is bound to SessionData.recentColors[0] (Modals/ColorPickerModal.qml:13). The binding stays live when the picker is opened with plain open/toggle, because no caller assigns it in that case. So this write triggers onSelectedColorChanged, which calls setColor(...): the editor jumps to the next recent color, or to Theme.primary once the list is empty, and the user's in-progress color is lost. Until now recentColors only changed through addRecentColor(currentColor), so this never showed.

Fix: make selectedColor a plain value, not a live binding. For example, seed it from recentColors[0] in show() when no caller set a color, so later edits to the recent list don't touch an open picker.

@claude

claude Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Claude review

One bug to fix before merge.

  • Removing the first recent color resets the open picker's color, through the live selectedColor binding in ColorPickerModal, quickshell/Common/SessionData.qml:1520
    Checked: SessionData.removeRecentColor, swatch right-click/Delete handling against DColorButton/StyledButton/StateLayer, tooltip i18n, ColorPickerModal bindings, new node test. Model: claude-opus-5-5.

@apollo79

Copy link
Copy Markdown
Contributor
  • it is quite usual that Backspace triggers the same action as Delete

The right-click path was not tested live, because I had no way to send a mouse click into the nested session. It calls the same function through a TapHandler limited to Qt.RightButton.

? I guess it's fine letting your AI write everything but you could test it yourself and adjust the text here.

I must say I also don't like a simple right click to remove. This is not a usual interaction as far as I am aware.

@Mario-Mohar Mario-Mohar changed the title color picker: remove recent colors with right-click or delete color picker: remove recent colors with a hover button, delete or backspace Oct 12, 2026
@Mario-Mohar

Copy link
Copy Markdown
Contributor Author

@apollo79 thanks, good points. Right-click is gone, hovering a swatch now shows a small close button, and Backspace works like Delete. I clicked through it myself and updated the description.

The review finding was real: removing the first recent color reset the color being edited. Fixed in ColorPickerModal, before/after screenshots are in the description.

This branch has not been deployed

No deployments
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.

Ability to selectively remove recently picked colors in color picker

3 participants