luci-proto-wireguard: Hide the QR code parent dialogue button row via styling
authorPaul Donald <[email protected]>
Tue, 28 Oct 2025 16:36:53 +0000 (17:36 +0100)
committerPaul Donald <[email protected]>
Tue, 28 Oct 2025 16:36:53 +0000 (17:36 +0100)
Previously, the render code attempted to add the class "hidden" to the button
row, the button row which can have a persistent visibility style applied via CSS
so the "hidden" class attribute was overridden. Set the style.display of the row
instead which now hides the button row.

Signed-off-by: Paul Donald <[email protected]>
protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js

index e1e1835c7bad148eaef9efaed1afff795453aa7f..fd516d7c754f2fdbc92e0a275d68323944c4b60f 100644 (file)
@@ -832,8 +832,14 @@ return network.registerProtocol('wireguard', {
                                };
 
                                return qrm.render().then(function(nodes) {
-                                       mapNode.classList.add('hidden');
-                                       mapNode.nextElementSibling.classList.add('hidden');
+                                       // stash the current dialogue style (visible)
+                                       const dStyle = mapNode.style;
+                                       // hide the current modal window
+                                       mapNode.style.display = 'none';
+                                       // stash the current button row style (visible)
+                                       const bRowStyle = mapNode.nextElementSibling.style;
+                                       // hide the [ Dismiss | Save ] button row
+                                       mapNode.nextElementSibling.style.display = 'none';
 
                                        headNode.appendChild(E('span', [ ' » ', _('Generate configuration') ]));
                                        mapNode.parentNode.appendChild(E([], [
@@ -844,10 +850,15 @@ return network.registerProtocol('wireguard', {
                                                        E('button', {
                                                                'class': 'btn',
                                                                'click': function() {
+                                                                       // Remove QR code button (row)
                                                                        nodes.parentNode.removeChild(nodes.nextSibling);
+                                                                       // Remove QR code form
                                                                        nodes.parentNode.removeChild(nodes);
-                                                                       mapNode.classList.remove('hidden');
-                                                                       mapNode.nextSibling.classList.remove('hidden');
+                                                                       // unhide the WiFi modal dialogue
+                                                                       mapNode.style = dStyle;
+                                                                       // Revert button row style to visible again
+                                                                       mapNode.nextSibling.style = bRowStyle;
+                                                                       // Remove the H4 span (») title
                                                                        headNode.removeChild(headNode.lastChild);
                                                                }
                                                        }, [ _('Back to peer configuration') ])