Skip to content

Commit

Permalink
fix: enter/return adds top result tag (#651)
Browse files Browse the repository at this point in the history
* fix return not adding searched tag

* add first_tag_id type hint
  • Loading branch information
SkeleyM authored Dec 21, 2024
1 parent 36c1c18 commit 934c98a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tagstudio/src/qt/modals/tag_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, library: Library, exclude: list[int] | None = None):
self.lib = library
self.exclude = exclude
self.is_initialized: bool = False
self.first_tag_id = None
self.first_tag_id: int = None
self.setMinimumSize(300, 400)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 0, 6, 0)
Expand Down Expand Up @@ -69,14 +69,18 @@ def on_return(self, text: str):
self.update_tags()
else:
self.search_field.setFocus()
self.parentWidget().hide()
self.parentWidget().hide()

def update_tags(self, query: str | None = None):
logger.info("[Tag Search Modal] Updating Tags")
while self.scroll_layout.count():
self.scroll_layout.takeAt(0).widget().deleteLater()

tag_results = self.lib.search_tags(name=query)
if len(tag_results) > 0:
self.first_tag_id = tag_results[0].id
else:
self.first_tag_id = None

for tag in tag_results:
if self.exclude is not None and tag.id in self.exclude:
Expand Down

0 comments on commit 934c98a

Please sign in to comment.