Duplicate “Add” buttons on child object list views #11570

Closed
opened 2025-12-29 21:46:53 +01:00 by adam · 2 comments
Owner

Originally created by @pheus on GitHub (Sep 4, 2025).

Originally assigned to: @pheus on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.4.0

Python Version

3.10

Steps to Reproduce

Minimal example (Prefixes → Child Prefixes):

  1. Create a parent prefix (e.g., 10.0.0.0/8).
  2. Open the parent prefix’s detail view.
  3. Navigate to the Child Prefixes view for that prefix.
  4. Observe two buttons at the top right: a contextual Add Prefix button and a generic Add button.

Also reproducible on other child views (examples):

  • Prefixes → Child Ranges
  • Racks → Non-racked Devices
  • Device → Contacts

Expected Behavior

Only one add action should be presented: the contextual add button for the specific child view (e.g., Add Prefix on Child Prefixes).

Observed Behavior

Both a contextual add button (e.g., Add Prefix) and a generic Add button are displayed. The generic Add button opens the create form without pre-populating the parent context.

Image
Originally created by @pheus on GitHub (Sep 4, 2025). Originally assigned to: @pheus on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.4.0 ### Python Version 3.10 ### Steps to Reproduce *Minimal example (Prefixes → Child Prefixes):* 1. Create a parent prefix (e.g., `10.0.0.0/8`). 2. Open the parent prefix’s detail view. 3. Navigate to the **Child Prefixes** view for that prefix. 4. Observe two buttons at the top right: a contextual **Add Prefix** button and a generic **Add** button. *Also reproducible on other child views (examples):* - **Prefixes → Child Ranges** - **Racks → Non-racked Devices** - **Device → Contacts** ### Expected Behavior Only one add action should be presented: the contextual add button for the specific child view (e.g., **Add Prefix** on Child Prefixes). ### Observed Behavior Both a contextual add button (e.g., **Add Prefix**) and a generic **Add** button are displayed. The generic **Add** button opens the create form without pre-populating the parent context. <img width="1814" height="732" alt="Image" src="https://github.com/user-attachments/assets/0eaf91b0-ae16-4b58-b633-13e70c2fbd23" />
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:46:53 +01:00
adam closed this issue 2025-12-29 21:46:54 +01:00
Author
Owner

@pheus commented on GitHub (Sep 4, 2025):

Thanks for the work on ObjectActions in #19774 !

While reviewing the duplicate “Add” buttons reported above, it appears that ObjectChildrenView now registers the generic AddObject action for child views. In prior releases, child views registered only their context‑specific add action.

Because most child views in core (and many plugins) already provide a context‑specific add action, the generic registration results in two “Add” buttons on child lists; the generic one also doesn’t pre‑populate the parent context.

Proposal: Remove the generic AddObject registration from ObjectChildrenView (or skip it when a view defines a specific add action).

ea50786b5c/netbox/netbox/views/generic/object_views.py (L106)

I’m happy to open a PR to implement this if the approach sounds reasonable. If there’s background or use‑cases I’m missing, please let me know. Thanks!

@pheus commented on GitHub (Sep 4, 2025): Thanks for the work on ObjectActions in #19774 ! While reviewing the duplicate “Add” buttons reported above, it appears that `ObjectChildrenView` now registers the generic `AddObject` action for child views. In prior releases, child views registered only their context‑specific add action. Because most child views in core (and many plugins) already provide a context‑specific add action, the generic registration results in two “Add” buttons on child lists; the generic one also doesn’t pre‑populate the parent context. **Proposal:** Remove the generic `AddObject` registration from `ObjectChildrenView` (or skip it when a view defines a specific add action). https://github.com/netbox-community/netbox/blob/ea50786b5c68af6ca7eca91cfde36f8211f6b44b/netbox/netbox/views/generic/object_views.py#L106 I’m happy to open a PR to implement this if the approach sounds reasonable. If there’s background or use‑cases I’m missing, please let me know. Thanks!
Author
Owner

@bctiemann commented on GitHub (Sep 5, 2025):

Sounds reasonable to me; we'll review the PR for any side effects it mght have. Thanks @pheus !

@bctiemann commented on GitHub (Sep 5, 2025): Sounds reasonable to me; we'll review the PR for any side effects it mght have. Thanks @pheus !
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11570