netbox icon indicating copy to clipboard operation
netbox copied to clipboard

HTMX Allow updating sub-parts of forms without re-rendering entire form

Open arthanson opened this issue 1 year ago • 0 comments

NetBox version

v3.7.2

Feature type

Change to existing functionality

Proposed functionality

Currently we can re-render forms via HTMX when you change a select field to change the fields that are displayed (for example if you add an interface and change the 802.1Q selection).

What happens is the entire form is re-rendered via HTMX (causing a slight flash as the entire form is re-rendered). The proposal would be to allow specifying and updating just a sub-set of the fields, not just the whole form.

Use case

The issue with the current implementation is that on larger forms (like the interface form) There is a UI 'flash' as the entire form is re-rendered. Just updating the subset of fields instead of the whole form should make for a smoother experience.

Discussing with Jeremy this could probably be done by either tying the fields to a fieldset and having HTMX handle rendering of the fieldset, or else using https://htmx.org/attributes/hx-select/ Tying it to a fieldset might also make the implementation of forms more DRY as you could potentially just mark fieldsets as handled via HTMX and the underlying form-view class could auto handle the return info instead of currently how we handle the return in each form-view individually.

Database changes

None

External dependencies

None

arthanson avatar Feb 15 '24 16:02 arthanson