Fixes #20551: Support quick-add form prefix in automatic slug generation #20624
+24
−6
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.
Fixes: #20551
The slug generation logic in
reslug.ts
looks for form fields using hard-coded ID selectors like#id_slug
and#id_name
. In quick-add modals, Django applies aquickadd
prefix to form fields (introduced in #20542), resulting in IDs like#id_quickadd-slug
and#id_quickadd-name
. The logic couldn't find these prefixed fields, so automatic slug generation failed silently in quick-add modals.This fix updates the field selectors to try both unprefixed and prefixed patterns using the nullish coalescing operator (
??
). The logic checks for the standard field ID first and falls back to the quickadd-prefixed ID if the standard one isn't found.Manually tested automatic slug generation in both direct add forms and quick-add modals. Both the blur event (tab out of name field) and the explicit slug button click work correctly.