From 4da5e11653ab3b56d0b48ecb4e24c3cd97f2c6db Mon Sep 17 00:00:00 2001 From: LaurentGH <31282893+LaurentGH@users.noreply.github.com> Date: Wed, 5 Nov 2025 17:07:35 +0100 Subject: [PATCH] Error message when cancelling a label creation When "Create label" menu is clicked, a popup asks for the label name. If the Cancel button is immediately entered, an error message is displayed: TypeError: can't access property "trim", caption is null. Indeed, the JavaScript prompt() message returns null when Cancel is pressed. The test "caption !== undefined" is thus true, and the trim() is tried on null, which fails. The fix is to only check for "caption" or "caption != null". --- js/CommonDialogs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 491ebe426..e2dbfd3b0 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -325,7 +325,7 @@ const CommonDialogs = { addLabel: function() { const caption = prompt(__("Please enter label caption:"), ""); - if (caption !== undefined && caption.trim().length > 0) { + if (caption && caption.trim().length > 0) { const query = {op: "Pref_Labels", method: "add", caption: caption.trim()};