Forráskód Böngészése

Fixes #20134: Prevent HTMX OOB swaps in embedded tables (#20811)

The htmx/table.html template was unconditionally including out-of-band
(OOB) swaps for UI elements that only exist on list pages, causing
htmx:oobErrorNoTarget errors when tables were embedded on detail pages.

This change adds checks for table.embedded to conditionally exclude OOB
swaps for .total-object-count, #table_save_link, and .bulk-action-buttons
when rendering embedded tables via the htmx_table template tag.
Jason Novinger 2 hónapja
szülő
commit
05f254a768
1 módosított fájl, 5 hozzáadás és 3 törlés
  1. 5 3
      netbox/templates/htmx/table.html

+ 5 - 3
netbox/templates/htmx/table.html

@@ -17,15 +17,17 @@
 
 
 {% if request.htmx %}
 {% if request.htmx %}
   {# Include the updated object count for display elsewhere on the page #}
   {# Include the updated object count for display elsewhere on the page #}
-  <div hx-swap-oob="innerHTML:.total-object-count">{{ table.rows|length }}</div>
+  {% if not table.embedded %}
+    <div hx-swap-oob="innerHTML:.total-object-count">{{ table.rows|length }}</div>
+  {% endif %}
 
 
   {# Include the updated "save" link for the table configuration #}
   {# Include the updated "save" link for the table configuration #}
-  {% if table.config_params %}
+  {% if table.config_params and not table.embedded %}
     <a class="dropdown-item" hx-swap-oob="outerHTML:#table_save_link" href="{% url 'extras:tableconfig_add' %}?{{ table.config_params }}&return_url={{ request.path }}" id="table_save_link">Save</a>
     <a class="dropdown-item" hx-swap-oob="outerHTML:#table_save_link" href="{% url 'extras:tableconfig_add' %}?{{ table.config_params }}&return_url={{ request.path }}" id="table_save_link">Save</a>
   {% endif %}
   {% endif %}
 
 
   {# Update the bulk action buttons with new query parameters #}
   {# Update the bulk action buttons with new query parameters #}
-  {% if actions %}
+  {% if actions and not table.embedded %}
     <div class="bulk-action-buttons" hx-swap-oob="outerHTML:.bulk-action-buttons">
     <div class="bulk-action-buttons" hx-swap-oob="outerHTML:.bulk-action-buttons">
       {% action_buttons actions model multi=True %}
       {% action_buttons actions model multi=True %}
     </div>
     </div>