From 538ef5a9a05bb96fbbd85184c0665a70a6ea54f4 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Mon, 17 Nov 2025 21:10:49 +0100 Subject: [PATCH 1/2] fix the order of clearing and populating data --- assets/js/sections/qso.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 69e1a6d64..07bf29371 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -746,6 +746,13 @@ bc.onmessage = function (ev) { } else { // Always process frequency, callsign, and reference data from bandmap // (regardless of manual mode - bandmap should control the form) + let delay = 0; + + // Only reset if callsign is different from what we're about to set + if ($("#callsign").val() != "" && $("#callsign").val() != ev.data.call) { + reset_fields(); + delay = 600; + } // Store references for later population (after callsign lookup completes) pendingReferences = { @@ -755,13 +762,6 @@ bc.onmessage = function (ev) { iota_ref: ev.data.iota_ref }; - let delay = 0; - // Only reset if callsign is different from what we're about to set - if ($("#callsign").val() != "" && $("#callsign").val() != ev.data.call) { - reset_fields(); - delay = 600; - } - setTimeout(() => { if (ev.data.frequency != null) { $('#frequency').val(ev.data.frequency).trigger("change"); @@ -1056,7 +1056,11 @@ function reset_to_default() { } /* Function: reset_fields is used to reset the fields on the QSO page */ -function reset_fields() { +function reset_fields() { + // we set the pendingReferences to null to avoid they get prefilled in the next QSO after clear + // we do this first to avoid race conditions for slow javascript + pendingReferences = null; + $('#locator_info').text(""); $('#comment').val(""); $('#country').val(""); @@ -1129,9 +1133,6 @@ function reset_fields() { var selectize = $select[0].selectize; selectize.clear(); - // also set the pendingReferences to null to avoid they get prefilled in the next QSO after clear - pendingReferences = null; - $('#notes').val(""); $('#sig').val(""); From 390be4f78c232fd04c8cd661dfe1b3ce341cc1f8 Mon Sep 17 00:00:00 2001 From: Szymon Porwolik Date: Mon, 17 Nov 2025 23:12:13 +0100 Subject: [PATCH 2/2] Fix when user changes the callsign --- assets/js/sections/qso.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 07bf29371..cad646487 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -1056,7 +1056,7 @@ function reset_to_default() { } /* Function: reset_fields is used to reset the fields on the QSO page */ -function reset_fields() { +function reset_fields() { // we set the pendingReferences to null to avoid they get prefilled in the next QSO after clear // we do this first to avoid race conditions for slow javascript pendingReferences = null; @@ -1212,8 +1212,13 @@ $("#callsign").on("focusout", function () { lookupInProgress = true; // Capture pendingReferences for THIS lookup (before it gets overwritten by another click) + // If pendingReferences exists, use it; otherwise set to null to prevent old references + // from being populated when user manually types a different callsign var capturedReferences = pendingReferences ? Object.assign({}, pendingReferences) : null; + // Clear pendingReferences immediately after capturing to prevent reuse on next manual lookup + pendingReferences = null; + // Disable Save QSO button and show fetch status $('#saveQso').prop('disabled', true); $('#fetch_status').show();