processwire-issues
processwire-issues copied to clipboard
`wakeupValue()` being called on fields in AJAX loaded tab before it is viewed.
Short description of the issue
If you have a fieldsetTab, the wakeupValue() of the contained fields is called on page load - it doesn't wait until the tab is loaded.
Expected behavior
wakeupValue() would not be called until the tab is opened.
Actual behavior
Whenever you load a page for editing, the wakeupValue() for fields in an AJAX loaded tab is called immediately. This isn't a huge deal for simple fields, but when the tab contains large table fields or RuntimeOnly fields, then this negates most of the advantage of the AJAX loading. Note the render() does wait to be called (as expected), but that's not enough to help with the performance, especially if the tab contains a table field that is locked for editing.
Steps to reproduce the issue
- Add a Table field to an AJAX loaded fieldset Tab.
- Load the page for editing. If you add
bd('test');to the __wakeupValue() method in FieldtypeTable.module you'll see it fires even before you view the tab.
Note that the "Open in Modal Window" option works as expected, but it's not really a great user experience so it would be great to be able to have the same speed improvements with the AJAX loaded option.
@adrianbj Unfortunately I don't know of a way to support that at present, but I really like the idea. The ajax-loaded tabs or fields are a feature of Inputfield forms, not the page editor. So they are pretty far separated. Not even the modal option can get by this, so I'm not sure why you didn't see wakeupValue for the modal test. I'll give it more thought to see if there's a way to support that feature, as it does seem like a good one.
Hi @ryancramerdesign - thanks, glad you are interested in supporting this. Here's a little more info that might help, although some of it seems a little confusing.
If I add if($field->name == 'table_field_name') bd('test'); to the top of the ___wakeupValue method, it gets dumped 4 times when loading the page with the tab loaded normally.
If I make the tab which contains the table field load in a modal, then test is only dumped 3 times and the page loads in half the time.
If I make the tab load via AJAX, then test is dumped 4 times on initial page (and the load is slow again) and another 4 times when I open the tab.
Hi @ryancramerdesign - I'd love to nudge you on this because the modal approach definitely makes the main page load much faster, but the AJAX version has no impact on that initial page load, so there is definitely something going on. The modal is an OK solution, but not really ideal.