mirror of
https://github.com/opnsense/core.git
synced 2026-02-03 20:39:42 -05:00
Firewall: Rules [new]: Theory for race condition during selectpicker population
This commit is contained in:
parent
5276f51dc0
commit
551c4bcf40
1 changed files with 22 additions and 0 deletions
|
|
@ -864,6 +864,28 @@
|
|||
|
||||
// Hook into add event
|
||||
$('#{{formGridFilterRule["edit_dialog_id"]}}').on('opnsense_bootgrid_mapped', function(e, actionType) {
|
||||
if (actionType === 'edit' || actionType === 'clone') {
|
||||
/*
|
||||
* During rule edit, bootgrid maps values into the underlying inputs
|
||||
* after bootstrap-select has already been initialized.
|
||||
*
|
||||
* bootstrap-select does not observe programmatic value changes,
|
||||
* which can leave the UI desynced ("Nothing selected") even though
|
||||
* the value and option exist.
|
||||
*
|
||||
* Explicitly sync the picker to fix this.
|
||||
*/
|
||||
['source_net', 'source_port', 'destination_port', 'destination_net'].forEach(function (name) {
|
||||
const $input = $('#rule\\.' + name);
|
||||
const value = $input.val();
|
||||
const $select = $('select[for="rule.' + name + '"]');
|
||||
|
||||
if (value && $select.length) {
|
||||
$select.val(Array.isArray(value) ? value : [value]).selectpicker('refresh');
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (actionType === 'add') {
|
||||
// and choose same interface in new rule as selected in #interface_select
|
||||
const selectedInterface = $('#interface_select').val();
|
||||
|
|
|
|||
Loading…
Reference in a new issue