Ticket #13137 (confirmed Bug)

Opened 4 years ago

Last modified 4 years ago

form_tabbing.js is not defensive against multiple initializations

Reported by: seanupton Owned by:
Priority: minor Milestone: 4.x
Component: JavaScript Version: 4.2
Keywords: Cc:

Description (last modified by seanupton) (diff)

Multiple calls of ploneFormTabbing.initialize() in JavaScript, whether by design or accident will lead to duplicative ul.formTabs in the DOM for a form. I have ested this with z3c.form on Dexterity add forms.

Duplication (not sure why this triggers multiple intialization, this is an edge case, but the point is that the JS should be more defensive):

  1. Create a custom add form class and add view class for a Dexterity type. Set a custom template attribute on the add form class, and in that template, include <metal:block use-macro="context/@@ploneform-macros/titlelessform" />. Register view fronting for the form in ZCML as a normal browser view, then...
  1. Visit that browser view with ?ajax_load=1&ajax_include_head=1 in the query string.

In doing this, I see two stacked sets of form tabs for one form. The point isn't my (edge-case) form setup, but the fact that form_tabbing does not clear state before re-initializing. In my template I add a JS snippet to work around this:

jq('ul.formTabs').remove();
ploneFormTabbing.initialize();

We really should make form_tabbing.js defensive, clearing all form tabs for all forms on page before completely re-initializing them.

Change History

comment:1 Changed 4 years ago by seanupton

  • Description modified (diff)

Updated javascript for workaround, (correctly) use remove() instead of empty().

comment:2 Changed 4 years ago by kleist

  • Keywords javascript removed
  • Status changed from new to confirmed
  • Component changed from Unknown to JavaScript
Note: See TracTickets for help on using tickets.