mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-16 15:01:03 +00:00
Backport #40349 by @silverwind Dropdowns initialized without an options object shared the default Fomantic templates, so the ARIA patch kept wrapping `templates.menu` on the defaults and retained every dropdown ever created. This grows memory on the Actions run list, which re-renders its dropdowns on each refresh. Each dropdown now gets its own templates copy, which the ARIA patch modifies in place. Fixes: https://github.com/go-gitea/gitea/issues/40347 Assisted-by: Claude Code:claude-opus-5-5 Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
1 parent
95b69a4a2d
commit
87c509a405
3 files changed
+10
-4
No files matched your search
@@ -1,8 +1,12 @@
|
||||
import '../../../fomantic/build/fomantic.js';
|
||||
import {initGiteaFomantic} from '../fomantic.ts';
|
||||
import {createElementFromHTML} from '../../utils/dom.ts';
|
||||
import {hideScopedEmptyDividers} from './dropdown.ts';
|
||||
|
||||
test('dropdown-item-literal-text', () => {
|
||||
initGiteaFomantic();
|
||||
|
||||
test('dropdown-item-literal-text-and-default-templates-untouched', () => {
|
||||
const defaultTemplates = {...$.fn.dropdown.settings.templates};
|
||||
// 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">
|
||||
@@ -16,6 +20,9 @@ test('dropdown-item-literal-text', () => {
|
||||
expect($dropdown.dropdown('get text')).toEqual(value);
|
||||
expect($dropdown.dropdown('get value')).toEqual(value);
|
||||
}
|
||||
$dropdown.dropdown('change values', [{name: 'dynamic', value: 'dynamic'}]);
|
||||
expect($dropdown.closest('.ui.dropdown').find('[data-item-dynamic]').attr('role')).toEqual('menuitem');
|
||||
expect($.fn.dropdown.settings.templates).toEqual(defaultTemplates);
|
||||
});
|
||||
|
||||
test('hideScopedEmptyDividers-simple', () => {
|
||||
|
||||
@@ -90,7 +90,7 @@ function delegateDropdownModule($dropdown: JQueryElem<AriaDropdownElement>) {
|
||||
const dropdownCall = fomanticDropdownFn.bind($dropdown);
|
||||
|
||||
// the "template" functions are used for dynamic creation (eg: AJAX)
|
||||
const dropdownTemplates = {...dropdownCall('setting', 'templates'), t: performance.now()};
|
||||
const dropdownTemplates = dropdownCall('setting', 'templates');
|
||||
const dropdownTemplatesMenuOld = dropdownTemplates.menu;
|
||||
dropdownTemplates.menu = function(response: any, fields: any, preserveHTML: any, className: Record<string, string>) {
|
||||
// when the dropdown menu items are loaded from AJAX requests, the items are created dynamically
|
||||
@@ -103,7 +103,6 @@ function delegateDropdownModule($dropdown: JQueryElem<AriaDropdownElement>) {
|
||||
$dropdown[0][ariaPatchKey].deferredRefreshAriaActiveItem();
|
||||
return $wrapper.html();
|
||||
};
|
||||
dropdownCall('setting', 'templates', dropdownTemplates);
|
||||
|
||||
// the `onLabelCreate` is used to add necessary aria attributes for dynamically created selection labels
|
||||
const dropdownOnLabelCreateOld = dropdownCall('setting', 'onLabelCreate');
|
||||
|
||||
Reference in new issue
Block a user