Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions python/context_selector/context_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,18 @@ def _on_context_activated(self, context):
def _on_entity_activated(self, entity_type, entity_id, entity_name):
"""
Slot called when an entity is selected via one of the search completers.

Since ``context_from_entity`` doesn't guarantee "name" field to be populated,
fallback to use ``entity_name`` if it's missing.
"""
bundle = sgtk.platform.current_bundle()
context = bundle.sgtk.context_from_entity(entity_type, entity_id)
if entity_type == "Project":
context.project.setdefault("name", entity_name)
elif entity_type == "Task":
context.task.setdefault("name", entity_name)
else:
context.entity.setdefault("name", entity_name)
self._on_context_activated(context)

def _on_task_search_toggled(self, checked):
Expand Down