Fixes #20551: Support quick-add form prefix in automatic slug generation #1028

Closed
opened 2026-04-05 19:55:36 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @jnovinger on 10/19/2025

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 a quickadd 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.

*Originally created by @jnovinger on 10/19/2025* 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 a `quickadd` 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.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#1028