fix: keep literal "false" value displayed in workflow_dispatch choice dropdowns (#38080)

This commit is contained in:
bircni
2026-06-12 15:26:51 +02:00
committed by GitHub
parent f5a97b7518
commit 15ae1bfc8c
2 changed files with 21 additions and 4 deletions

View File

@@ -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')
;

View File

@@ -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 = $(`<select class="ui dropdown">
<option value="1">1</option>
<option value="0">0</option>
<option value="true">true</option>
<option value="false">false</option>
</select>`).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(`<div>
<div class="divider"></div>