fix(editor): Create tag when a new workflow tag is selected #9691
+27
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request addresses the issue where saving a workflow with a non-existing tag raises an error (
SQLITE_CONSTRAINT: FOREIGN KEY constraint failed
for SQLite orinsert or update on table "workflows_tags" violates foreign key constraint "fk_workflows_tags_tag_id"
for Postgres).Previously, when a user entered a filter value, the menu offered an option to create a new tag named after the filter value (
Create tag "..."
). Additionally, the filter value was displayed as the first entry in the tag list, allowing the user to select it directly. However, selecting this item added the tag to the model but did not create it in the database.With this update, both actions—clicking on the "create" menu entry and selecting the new tag—will now consistently create the tag in the database. This ensures that any new tag added via the dropdown menu is properly created and saved.
Additionally, this PR improves the condition for displaying the "create" action item. Previously, it was shown only when the filtered list was empty. Now, it is displayed whenever the filter value does not match an existing tag. While this change is beneficial, it might be better suited for a separate PR. Please let me know if you would like me to separate it.
This change was manually tested based on the issue description #9132. Please let me know if there are recommended ways to write an automated test for this case.
Related tickets and issues
Fixes #9132.
Review / Merge checklist
(no-changelog)
otherwise. (conventions)