[PR #20624] [MERGED] Fixes #20551: Support quick-add form prefix in automatic slug generation #15987

Closed
opened 2025-12-30 00:25:10 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/20624
Author: @jnovinger
Created: 10/20/2025
Status: Merged
Merged: 10/21/2025
Merged by: @jeremystretch

Base: mainHead: 20551-quickadd-slug-generation


📝 Commits (2)

  • 4e5db95 Fixes #20551: Support quick-add form prefix in automatic slug generation
  • 2803b18 Address PR feedback

📊 Changes

6 files changed (+24 additions, -6 deletions)

View changed files

📝 netbox/project-static/dist/netbox.js (+1 -1)
📝 netbox/project-static/dist/netbox.js.map (+2 -2)
📝 netbox/project-static/src/buttons/reslug.ts (+4 -2)
📝 netbox/utilities/forms/fields/fields.py (+8 -0)
📝 netbox/utilities/forms/widgets/misc.py (+8 -0)
📝 netbox/utilities/templates/form_helpers/render_field.html (+1 -1)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/20624 **Author:** [@jnovinger](https://github.com/jnovinger) **Created:** 10/20/2025 **Status:** ✅ Merged **Merged:** 10/21/2025 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `main` ← **Head:** `20551-quickadd-slug-generation` --- ### 📝 Commits (2) - [`4e5db95`](https://github.com/netbox-community/netbox/commit/4e5db958c4e0a854e85b4199619eb3253a18c96e) Fixes #20551: Support quick-add form prefix in automatic slug generation - [`2803b18`](https://github.com/netbox-community/netbox/commit/2803b18699b7c81c70d5f697a84df8afbc2d094b) Address PR feedback ### 📊 Changes **6 files changed** (+24 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `netbox/project-static/dist/netbox.js` (+1 -1) 📝 `netbox/project-static/dist/netbox.js.map` (+2 -2) 📝 `netbox/project-static/src/buttons/reslug.ts` (+4 -2) 📝 `netbox/utilities/forms/fields/fields.py` (+8 -0) 📝 `netbox/utilities/forms/widgets/misc.py` (+8 -0) 📝 `netbox/utilities/templates/form_helpers/render_field.html` (+1 -1) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:25:10 +01:00
adam closed this issue 2025-12-30 00:25:11 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15987