Skip to content

New/RFC: Saved Filter List refactor - #7224

Open
Gykes wants to merge 2 commits into
stashapp:developfrom
Gykes:SavedFilterRefactor
Open

New/RFC: Saved Filter List refactor#7224
Gykes wants to merge 2 commits into
stashapp:developfrom
Gykes:SavedFilterRefactor

Conversation

@Gykes

@Gykes Gykes commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR refactors the filter list dropdown to be slightly more in line with modern expectations. I made some changes from the original PR. I didn't like that when renaming it would open a new modal and then close the filter list. This would cause more mouse clicks and it was annoying so I kept it all in house and you can now change the name inside the same modal.

Related Issue

closes #4077

Testing

Tested in dev environment

Screenshots

general dropdown rename

Checklist

  • I have read and understood the Contributing document.
  • I have read and understood the AI Usage Policy document.
  • I have made corresponding changes to the documentation (if applicable).

AI Usage Disclosure

  • I have used AI tools to assist with this pull request, and I have disclosed the tools and how I used them below.

Drafted with Claude Opus.

Additional Context

Supersedes: #4097.

Consolidate the per-filter actions in both the toolbar and the sidebar
saved filter lists into a single overflow menu, and add a rename
operation.

Renaming edits the name in place in the list rather than in a modal. A
modal is portalled to the document body, which the toolbar's saved filter
dropdown reads as a click outside itself, so the dropdown would close
behind it and the user would have to reopen it to carry on. Enter
confirms, escape or blur abandons.

Keeping that dropdown open takes some care, since it is asked to close by
three separate mechanisms. Choosing an operation forwards a nested menu's
select up through SelectableContext, and the operations menu is portalled
to the document body so it also reads as a click outside; the dropdown is
therefore controlled, and ignores a close while an operation is being
started. It uses a callback from the menu rather than inspecting the
event, because useRootClose evaluates containment in the capture phase,
before React has run its handlers, so by the time the close arrives the
clicked item may already be unmounted. Escape is the third: react-
overlays' Dropdown listens for it on keydown and useRootClose on keyup,
so the name input stops both and abandons the rename on keyup, while it
is still mounted to do so.

The filter is re-saved under its existing ID with the new name. Its
stored find_filter, object_filter and ui_options are passed through
untouched rather than round-tripped through ListFilterModel: a criterion
type the current UI doesn't recognise becomes an UnsupportedCriterion,
which neither reads itself in nor writes itself back, and saving replaces
object_filter wholesale - so a round-trip would silently delete such a
criterion. Legacy criteria like career_length and movies are affected.

Names are trimmed, and a rename onto an existing name is rejected before
saving rather than surfacing a raw uniqueness constraint error. As in
SaveFilterDialog the comparison is case-insensitive, even though the
unique index is not, to avoid a confusing "foo"/"Foo" pair. A rejected
rename leaves the name in the editor rather than discarding it.

The menu also allows an existing saved filter to be made the default for
the view. The toolbar menu's own Set as default button has been removed,
since having two controls with the same label in the one menu is
confusing and it did something different - it set the default from the
current filter rather than from a saved one. That remains available from
the sidebar, which is present on every view that has the toolbar.

OperationDropdown gains optional icon, id, title, size, toggle class and
onClick props so that the per-filter menu can reuse it instead of
duplicating it. All are defaulted, leaving existing callers unaffected.

Two components that were being declared during a render are no longer:
the dropdown's menu, and the toolbar's filter rows. Each was a new
component type on every render, remounting its subtree and discarding an
in-progress rename.
Also mention that saved filters are available in the filter sidebar, not
just in the toolbar bookmark menu, and that the current filter is set as
the default from the sidebar.
@Gykes
Gykes requested a review from DogmaDragon as a code owner September 10, 2026 18:38
@Gykes
Gykes requested a review from WithoutPants September 10, 2026 19:48
@Gykes Gykes added the feature Pull requests that add a new feature or functionality label Sep 10, 2026
@Gykes Gykes added this to the Version 0.32.0 milestone Sep 10, 2026

@DogmaDragon DogmaDragon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Documentation check passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Pull requests that add a new feature or functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter menu: Add rename option; Consolidate icon buttons into vertical overflow menu

2 participants