Skip to content

Commit 50b5aae

Browse files
committed
Reorder queue creation form to prevent vhost reset
When creating a queue in the management UI, selecting a non-`/` virtual host, then a queue type different than the default for that virtual host causes the vhost selection to reset to `/`. This happens because changing the queue type calls `update()`, which re-renders the entire form to display specific data for that virtual host, losing the user's virtual host selection. This change reorders the "Add a new queue" form fields so that "Type" appears before "Virtual host". Users now select the queue type first, triggering the form re-render before they make their vhost selection. This prevents the vhost reset without requiring JS wizardry/hacks to preserve form state across re-renders.
1 parent feeeb7c commit 50b5aae

File tree

1 file changed

+14
-14
lines changed
  • deps/rabbitmq_management/priv/www/js/tmpl

1 file changed

+14
-14
lines changed

deps/rabbitmq_management/priv/www/js/tmpl/queues.ejs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -227,20 +227,6 @@
227227
<div class="hider">
228228
<form action="#/queues" method="put">
229229
<table class="form">
230-
<% if (display.vhosts) { %>
231-
<tr>
232-
<th><label>Virtual host:</label></th>
233-
<td>
234-
<select name="vhost">
235-
<% for (var i = 0; i < vhosts.length; i++) { %>
236-
<option value="<%= fmt_string(vhosts[i].name) %>" <%= (vhosts[i].name === current_vhost) ? 'selected="selected"' : '' %>><%= fmt_string(vhosts[i].name) %></option>
237-
<% } %>
238-
</select>
239-
</td>
240-
</tr>
241-
<% } else { %>
242-
<tr><td><input type="hidden" name="vhost" value="<%= fmt_string(vhosts[0].name) %>"/></td></tr>
243-
<% } %>
244230
<tr>
245231
<th><label>Type:</label></th>
246232
<td>
@@ -258,6 +244,20 @@
258244
</select>
259245
</td>
260246
</tr>
247+
<% if (display.vhosts) { %>
248+
<tr>
249+
<th><label>Virtual host:</label></th>
250+
<td>
251+
<select name="vhost">
252+
<% for (var i = 0; i < vhosts.length; i++) { %>
253+
<option value="<%= fmt_string(vhosts[i].name) %>" <%= (vhosts[i].name === current_vhost) ? 'selected="selected"' : '' %>><%= fmt_string(vhosts[i].name) %></option>
254+
<% } %>
255+
</select>
256+
</td>
257+
</tr>
258+
<% } else { %>
259+
<tr><td><input type="hidden" name="vhost" value="<%= fmt_string(vhosts[0].name) %>"/></td></tr>
260+
<% } %>
261261
<tr>
262262
<th><label>Name:</label></th>
263263
<td><input type="text" name="name"/><span class="mand">*</span></td>

0 commit comments

Comments
 (0)