Closed thet closed 1 year ago
This seems a bit hacky. Can't we make the injection target depend on whether the training module is displayed?
Actually, I would not change this because it works better than expected:
The injection target replaces the whole element: source: #page-module-training::element; target: #page-module-training::element;
. When first rendered with no risks selected it is hidden. When a risk is selected and the injection happens the result already does not contain the display:hidden
style and the risk module is shown immediately. When unselecting the risk module is hidden immediately.
If we would fiddle with the injection depending on if there are selected risks or not we would only show/hide the risk module on a full reload/injection of the page.
Slightly related: what I found odd is:
1) after selecting a risk a pat-autosubmit initiated POSTs happens and the server responds with the already correct markup. But then another injection happens just to GET the same markup and to inject/replace the risk module (probably due to a second pat-inject defined on the fieldset of the risk checkboxes?).
2) besides of being loaded twice, the whole page is returned, not only relevant parts of it. We could save quite some templating logic if only the relevant parts would be returned. Or - instead of the style="display: none"
hack if we could use the CSS :has
pseudo selector instead (not yet available in Firefox) and instead of pat-inject we could do a pat-clone for the selected to be cloned into the training module.
Yes but that would complicate the code considerably. There is no funding for making this cleaner. Keep as is.
Ref: scrum-1205 item 2)