Skip to content

Commit

Permalink
fix(ui): don't always create tag on enter ( #731)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkeleyM authored Jan 25, 2025
1 parent 2a41c15 commit 921a887
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tagstudio/src/qt/modals/tag_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TagSearchPanel(PanelWidget):
tag_chosen = Signal(int)
lib: Library
is_initialized: bool = False
first_tag_id: int = None
first_tag_id: int | None = None
is_tag_chooser: bool
exclude: list[int]

Expand Down Expand Up @@ -202,10 +202,12 @@ def update_tags(self, query: str | None = None):
results_2.append(tag)
results_1.sort(key=lambda tag: len(tag.name))
results_2.sort()
self.first_tag_id = results_1[0].id if len(results_1) > 0 else tag_results[0].id
for tag in results_1 + results_2:
self.scroll_layout.addWidget(self.__build_row_item_widget(tag))
else:
# If query doesnt exist add create button
self.first_tag_id = None
c = self.construct_tag_button(query)
self.scroll_layout.addWidget(c)
self.search_field.setFocus()
Expand Down
2 changes: 1 addition & 1 deletion tagstudio/src/qt/widgets/preview_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self, library: Library, driver: "QtDriver"):
self.file_attrs = FileAttributes(library, driver)
self.fields = FieldContainers(library, driver)

self.tag_search_panel = TagSearchPanel(self.driver.lib)
self.tag_search_panel = TagSearchPanel(self.driver.lib, is_tag_chooser=True)
self.add_tag_modal = PanelModal(
self.tag_search_panel, Translations.translate_formatted("tag.add.plural")
)
Expand Down

0 comments on commit 921a887

Please sign in to comment.