From 15ae1bfc8ca0af8b6c641f7efa21724216dc08dd Mon Sep 17 00:00:00 2001 From: bircni Date: Fri, 12 Jun 2026 15:26:51 +0200 Subject: [PATCH] fix: keep literal "false" value displayed in workflow_dispatch choice dropdowns (#38080) --- web_src/fomantic/build/components/dropdown.js | 8 ++++---- web_src/js/modules/fomantic/dropdown.test.ts | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/web_src/fomantic/build/components/dropdown.js b/web_src/fomantic/build/components/dropdown.js index 0faed1858c4..f971fecda4c 100644 --- a/web_src/fomantic/build/components/dropdown.js +++ b/web_src/fomantic/build/components/dropdown.js @@ -1953,8 +1953,8 @@ $.fn.dropdown = function(parameters) { $choice.find(selector.menu).remove(); $choice.find(selector.menuIcon).remove(); } - return ($choice.data(metadata.text) !== undefined) - ? $choice.data(metadata.text) + return ($choice.attr('data-' + metadata.text) !== undefined) // GITEA-PATCH: use "attr" but not "data", don't decode JSON like "false" + ? $choice.attr('data-' + metadata.text) : (preserveHTML) ? $choice.html().trim() : $choice.text().trim() @@ -2007,8 +2007,8 @@ $.fn.dropdown = function(parameters) { value = ( $option.attr('value') !== undefined ) ? $option.attr('value') : name, - text = ( $option.data(metadata.text) !== undefined ) - ? $option.data(metadata.text) + text = ( $option.attr('data-' + metadata.text) !== undefined ) // GITEA-PATCH: use "attr" but not "data", don't decode JSON like "false" + ? $option.attr('data-' + metadata.text) : name, group = $option.parent('optgroup') ; diff --git a/web_src/js/modules/fomantic/dropdown.test.ts b/web_src/js/modules/fomantic/dropdown.test.ts index 542cb854b84..4ea51b3d2ce 100644 --- a/web_src/js/modules/fomantic/dropdown.test.ts +++ b/web_src/js/modules/fomantic/dropdown.test.ts @@ -1,6 +1,23 @@ +import '../../../fomantic/build/fomantic.js'; import {createElementFromHTML} from '../../utils/dom.ts'; import {hideScopedEmptyDividers} from './dropdown.ts'; +test('dropdown-item-literal-text', () => { + // a "choice" workflow_dispatch input can offer the string "false" as an option. + // jQuery `.data()` would coerce `data-text="false"` to the boolean `false`, which then renders as empty text. + const $dropdown = $(``).dropdown(); + for (const value of ['1', '0', 'true', 'false']) { + $dropdown.dropdown('set selected', value); + expect($dropdown.dropdown('get text')).toEqual(value); + expect($dropdown.dropdown('get value')).toEqual(value); + } +}); + test('hideScopedEmptyDividers-simple', () => { const container = createElementFromHTML(`