From 8a39acbeb1ac9555ca3767cdb2cb1db5861a1f8b Mon Sep 17 00:00:00 2001 From: LucasC Date: Mon, 1 Dec 2025 16:08:35 +0100 Subject: [PATCH] XWIKI-17296: Inconsistent dropdown behaviour between object and class editor * Removed a minor bug from the `Add property` button. When there was no name set for the property it would submit the edit form and open the preview of the doc?? AFAIU the type on this button should have been `button` (action unrelated to the form) instead of `submit` (the button purpose is to submit the form -- here the edition of the page). * Removed a minor bug where clicking on the reordering handle would also expand/collapse the section. * Fixed the default state. --- .../src/main/resources/flamingo/editclass.vm | 2 +- .../resources/js/xwiki/editors/dataeditors.js | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/editclass.vm b/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/editclass.vm index 6dc8924d2de7..63f5866845fa 100644 --- a/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/editclass.vm +++ b/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/editclass.vm @@ -140,7 +140,7 @@ $xwiki.jsfx.use('js/xwiki/editors/dataeditors.js', true)## - + #end diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/js/xwiki/editors/dataeditors.js b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/js/xwiki/editors/dataeditors.js index 3602d8da739f..13378dfa9282 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/js/xwiki/editors/dataeditors.js +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/js/xwiki/editors/dataeditors.js @@ -533,9 +533,9 @@ $.post(ref).done(function(data) { $('#xclassContent').append(data); let insertedPropertyElt = $('#xclassContent > div.xproperty:last-child'); - // Expand the newly inserted property, since the user will probably want to edit it once it was added - self.expandCollapseMetaProperty(insertedPropertyElt); - // Make teh newly added property sortable + // Make the newly added property collapsable since the user will probably want to edit it + self.expandCollapseMetaProperty(insertedPropertyElt, true); + // Make the newly added property sortable self.makeSortable(insertedPropertyElt); self.ajaxPropertyDeletion(insertedPropertyElt); self.makeDisableVisible(insertedPropertyElt); @@ -683,15 +683,18 @@ // ------------------------------------ // Class editor: expand-collapse meta properties - expandCollapseMetaProperty(property) { + expandCollapseMetaProperty(property, startExpanded = false) { let propertyTitle = property.find('.xproperty-title'); if (!propertyTitle) { // No such object... return; } property.addClass('collapsable'); - property.addClass('collapsed'); - propertyTitle.on('click', function() { + // By default, the property is collapsed when made collapsable. + if(!startExpanded) { + property.addClass('collapsed'); + } + propertyTitle.find('.toggle-collapsable, h2').on('click', function() { propertyTitle.parent().toggleClass('collapsed'); }); }