[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [FIX] Resetting preferences to default values hides the input but the values remain unchanged
"Merci Jacob \(@mercihabam\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <68dce2d499fd9_2cded50321e@gitlab-sidekiq-low-urgency-cpu-bound-v2-79f8d84998-58pn4.mail> |
Merci Jacob pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki Commits: 2c2d06b1 by Merci Jacob at 2025-10-01T08:14:04+00:00 [FIX] Resetting preferences to default values hides the input but the values remain unchanged --- * [FIX] Resetting preferences to default values hides the input but the values remain unchanged See merge request tikiwiki/tiki!8686 (cherry picked from commit 0b1cbdc0bfd4abc48d86e71f166ea03f4169105f) 2f4b8c8f [FIX] Resetting preferences to default values hides the input but the values remain unchanged Co-authored-by: Merci Jacob <[email protected]> - - - - - 3 changed files: - lib/jquery_tiki/tiki-jquery.js - src/js/vue-widgets/element-plus-ui/src/helpers/select/applySelect.js - src/js/vue-widgets/element-plus-ui/src/tests/helpers/select/applySelect.test.js Changes: ===================================== lib/jquery_tiki/tiki-jquery.js ===================================== @@ -4035,7 +4035,7 @@ $(document).on('click', '.pref-reset-wrapper a', function () { $(document).on('click', '.pref-reset', function() { var c = $(this).prop('checked'); - var $el = $(this).closest('.adminoptionbox').find('input:not(:hidden),select,textarea') + var $el = $(this).closest('.adminoptionbox').find('input,select,textarea') .not('.system').attr( 'disabled', c ) .css("opacity", c ? .6 : 1 ); var defval = $(this).data('preference-default'); @@ -4046,6 +4046,7 @@ $(document).on('click', '.pref-reset', function() { } else { $(this).data('preference-default', $el.val()); $el.val(defval); + $(`#${$el.attr('element-plus-ref')}`).attr('value', defval); // also reset element-plus if applicable } $el.trigger("change"); }); ===================================== src/js/vue-widgets/element-plus-ui/src/helpers/select/applySelect.js ===================================== @@ -23,8 +23,16 @@ export function observeSelectElementMutations(select, elementPlusUi) { $(elementPlusUi).removeAttr("is-invalid"); } } else if (mutation.attributeName) { + let attributeValue = mutation.target.getAttribute(mutation.attributeName); const attributeName = mutation.attributeName.replace("data-", ""); - $(elementPlusUi).attr(attributeName, mutation.target.getAttribute(mutation.attributeName)); + // skip "display: none;" value in the style attribute change + if (mutation.attributeName === "style") { + attributeValue = mutation.target + .getAttribute(mutation.attributeName) + .replace(/display:\s*none;?/g, "") + .trim(); + } + $(elementPlusUi).attr(attributeName, attributeValue); } }); }).observe(select, { childList: true, attributes: true }); ===================================== src/js/vue-widgets/element-plus-ui/src/tests/helpers/select/applySelect.test.js ===================================== @@ -8,13 +8,16 @@ describe("applySelect helper functions", () => { }); test.each([ - ["is-invalid", ["class", "is-invalid", "true"]], - ["is-invalid", ["class", "", null]], - ["max", ["data-max", "2", "2"]], - ["max", ["data-max", "", ""]], + ["is-invalid", ["is-invalid", "class", "is-invalid", "true"]], + ["is-invalid", ["is-invalid", "class", "", null]], + ["max", ["max", "data-max", "2", "2"]], + ["max", ["max", "data-max", "", ""]], + ["style", ["style", "style", "color: red;", "color: red;"]], + ["style ('display: none' ignored)", ["style", "style", "display: none;", ""]], + ["style ('display: none' ignored but other styles considered)", ["style", "style", "display: none; color: red;", "color: red;"]], ])( "observeSelectElementMutations is able to update the element-plus-ui %s attribute when relative changes occurs in the select element", - async (attribute, [selectAttribute, attributeValue, expectedValue]) => { + async (_, [elementPlusAttribute, selectAttribute, attributeValue, expectedValue]) => { const givenSelect = document.createElement("select"); const givenElementPlusUi = document.createElement("element-plus-ui"); document.body.append(givenSelect, givenElementPlusUi); @@ -23,12 +26,12 @@ describe("applySelect helper functions", () => { await window.happyDOM.waitUntilComplete(); - expect(givenElementPlusUi.getAttribute(attribute)).toBeNull(); + expect(givenElementPlusUi.getAttribute(elementPlusAttribute)).toBeNull(); givenSelect.setAttribute(selectAttribute, attributeValue); await window.happyDOM.waitUntilComplete(); - expect(givenElementPlusUi.getAttribute(attribute)).toBe(expectedValue); + expect(givenElementPlusUi.getAttribute(elementPlusAttribute)).toBe(expectedValue); } ); View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2c2d06b1c76d9d524593402fb5e24b70e521cb03 -- View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2c2d06b1c76d9d524593402fb5e24b70e521cb03 You're receiving this email because of your account on gitlab.com. _______________________________________________ TikiWiki-cvs mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs