Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nod_’s picture

What's the default for #open? I'm assuming TRUE in this patch. The html5 specs only talks about the open attribute so the default state is up to whoever generates the details element.

This patch is based on the patch over at #1852104: #type details: Remove #collapsible property.

nod_’s picture

Status: Postponed » Needs review
FileSize
35.76 KB

I like #open, makes more sense to use than #collapsed :)

sun’s picture

I'd say that #open should default to FALSE.

Normally, no #details should be opened by default, since they present "details you may skip over", by design.

+++ b/core/includes/form.inc
@@ -2880,7 +2880,7 @@ function theme_details($variables) {
-    $summary_attributes['aria-expanded'] = empty($element['#attributes']['open']) ? FALSE : TRUE;
+    $summary_attributes['aria-expanded'] = empty($element['#attributes']['open']);

Needs to use !empty() instead of empty()

+++ b/core/includes/form.inc
@@ -3972,8 +3972,8 @@ function form_pre_render_details($element) {
-    $element['#attributes']['open'] = 'open';
...
+    $element['#attributes']['open'] =  'open';

Double-space.

+++ b/core/lib/Drupal/Core/Database/Install/Tasks.php
@@ -234,7 +234,7 @@ public function getFormOptions($database) {
-      '#collapsed' => TRUE,
+      '#open' => FALSE,

+++ b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php
@@ -408,7 +408,7 @@ public function getSettingsForm() {
-      '#collapsed' => TRUE,
+      '#open' => FALSE,

All of the #open = FALSE, we should simply remove.

+++ b/core/modules/system/system.module
@@ -548,7 +548,7 @@ function system_element_info() {
   $types['details'] = array(
-    '#collapsed' => FALSE,
+    '#open' => TRUE,

Let's change this default value to FALSE.

star-szr’s picture

Status: Needs review » Needs work

CNW for #3, probably needs a reroll by now too.

nod_’s picture

Status: Needs work » Needs review
FileSize
39.54 KB

reroll and added fixed comments from #3

( edit ) Default state is closed. It's pretty interesting to see what it does to the admin UI :)

Jelle_S’s picture

Status: Needs review » Needs work
+++ b/core/modules/system/system.moduleundefined
@@ -554,7 +554,7 @@ function system_element_info() {
   $types['details'] = array(
-    '#collapsed' => FALSE,
+    '#open' => FALSE,

Should be '#open' => TRUE, if we want to keep the same behavior. If not, the attribute can be skipped, as you did throughout the rest of the patch

Edit: nvm, I think this is where the default behavior is described... default should be closed as stated in #3

+++ b/core/modules/system/tests/modules/design_test/form/fieldset.incundefined
@@ -40,7 +40,7 @@ function design_test_form_fieldset($form, &$form_state) {
   $form['collapsed']['#title'] = 'Collapsed details';
-  $form['collapsed']['#collapsed'] = TRUE;
+  $form['collapsed']['#open'] = FALSE;

Can be skipped as done throughout the rest of the patch. Doesn't have to obviously, but we might want to go for consistency?

Besides those small remaks, patch looks sane.

nod_’s picture

Status: Needs work » Needs review
FileSize
39.51 KB

fixed.

nod_’s picture

reroll

Wim Leers’s picture

Status: Needs review » Needs work
+++ b/core/includes/form.incundefined
@@ -2858,8 +2858,8 @@ function form_get_options($element, $key) {
+ *     Properties used: #attributes, #children, #description, #id, #title,
+ *     #value.
  *
  * @ingroup themeable
  */
@@ -2904,8 +2904,8 @@ function theme_fieldset($variables) {

@@ -2904,8 +2904,8 @@ function theme_fieldset($variables) {
  * @param $variables
  *   An associative array containing:
  *   - element: An associative array containing the properties of the element.
- *     Properties used: #attributes, #children, #collapsed, #description, #id,
- *     #title, #value.
+ *     Properties used: #attributes, #children, #description, #id, #title,

Where's #open? :)

Other than that, I couldn't find anything else to nitpick.

EDIT: nod_ pointed out that fieldsets shouldn't be collapsible anymore, so #open shouldn't exist there. But the second one is for theme_details(), and there #open should exist :)

Wim Leers’s picture

Status: Needs work » Reviewed & tested by the community

And now nod_ pointed out that theme_details() uses #attributes['open']… So the doxygen is correct.

alexpott’s picture

Needs a re-roll...

curl https://drupal.org/files/core-details-open-attr-1892182-8.patch | git apply
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 41098  100 41098    0     0  81857      0 --:--:-- --:--:-- --:--:--  431k
error: patch failed: core/modules/system/system.admin.inc:1870
error: core/modules/system/system.admin.inc: patch does not apply
nod_’s picture

Reroll. I left one #open => TRUE for the module page details. If all details are closed, the search doesn't work.

Status: Reviewed & tested by the community » Needs work
Issue tags: -API clean-up

The last submitted patch, core-details-open-attr-1892182-12.patch, failed testing.

nod_’s picture

Status: Needs work » Needs review
Issue tags: +API clean-up
nod_’s picture

Status: Needs review » Reviewed & tested by the community

Green, back to RTBC.

nod_’s picture

yannickoo’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/includes/form.incundefined
@@ -3929,8 +3929,8 @@ function form_pre_render_details($element) {
+    $element['#attributes']['open'] =  'open';

Double spaces?

nod_’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
40.87 KB

fixed the double space.

nod_’s picture

alexpott’s picture

Title: #type details: Rename #collapsed to #open » Change notice: #type details: Rename #collapsed to #open
Priority: Normal » Critical
Status: Reviewed & tested by the community » Active
Issue tags: +Needs change record

Committed c4e52bb and pushed to 8.x. Thanks!

nod_’s picture

Title: Change notice: #type details: Rename #collapsed to #open » #type details: Rename #collapsed to #open
Priority: Critical » Normal
Status: Active » Fixed

Updated http://drupal.org/node/1852020 with the info.

tim.plunkett’s picture

Status: Fixed » Needs work
Issue tags: +Needs manual testing

This change was slightly broken, and was not manually tested.
At least not in the Views UI, one of the largest users of details.
Views UI was broken when details was introduced, and now again.

The default for #collapsed was FALSE.
The default for #open is now FALSE.
Yet they are opposites.

On top of that, anything that was '#collapsed' => TRUE, was deleted.

However, anything that did not specify #collapsed did not have #open => TRUE added.

Either:
All of the old #collapsed => TRUE should have been switched to #open => FALSE and have the default for #open to be TRUE
All of the details elements with no #collapsed should have had #open => TRUE added.

tim.plunkett’s picture

Issue tags: -Needs manual testing
FileSize
17.65 KB

Actually this should probably be straight-up reverted. The issue title implies that one property was being renamed to another to improve DX, and yet it caused sweeping changes throughout the UI.

admin/content, admin/people, Views UI are all different. And those are just the first three I looked at.

For example, these used to be expanded:
used-to-be-expanded.png

git revert c4e52bb
xjm’s picture

Yeah, this is a pretty big WTF. E.g., the required fields in the installer are now hidden by default.

tim.plunkett’s picture

Issue tags: +Needs manual testing

@alexpott is in line to have his d.o email reset, but he reverted this.

He would have said:
"Reverted due to problems described in #22. Committed 687af78 and pushed to 8.x."

nod_’s picture

Issue tags: -Needs change record +Novice

I'll leave the pleasure or rerolling this one to someone else and the UI cleanup of form admin that should have ensued.

nod_’s picture

Status: Needs work » Needs review
FileSize
77.42 KB

whatever. It'll never get done otherwise.

longwave’s picture

Status: Needs review » Needs work

Almost all the #collapsed => TRUE are now #open => TRUE, but they should be #open => FALSE.

nod_’s picture

oh yeah I got confused when I applied the patch halfway.

Bojhan’s picture

@nod Yhea, so @sun is right it should default to closed. The problem is however that its currently implemented in the opposite way, so you'd have to check all forms in core and make sure the details that where open still are and the details that are closed also are. We open some by default, because it is our only grouping pattern beside VT's (so we kinda abuse this pattern). With that in mind I would side with the rest, to leave the default open for now.

++ On the renaming :)

jibran’s picture

Status: Needs work » Needs review
FileSize
72.58 KB
18.85 KB

oh yeah I got confused when I applied the patch halfway.

if #collapsed => TRUE remove it.
if #collapsed => FALSE or no #collapse add #open => TRUE.

nod_’s picture

Thanks a lot for the reroll :)

This one is good, I guess we need tim opinion now.

alexpott’s picture

I'm okay with the name change but I don't see why we're changing the default behaviour...

Having a fieldset open by default seems sensible to me... and the special case is when we want to add a fieldset and it default to the collapsed state.

Why not just...
if #collapsed => TRUE change to #open => FALSE
if #collapsed => FALSE remove it
leave #collapsible well alone
and default the #open to TRUE?

jibran’s picture

if #collapsed => TRUE change to #open => FALSE
if #collapsed => FALSE remove it

@sun has created the original patch in #1852104: #type details: Remove #collapsible property and I think only @sun can answer this question. Perhaps @nod_ can explain.

leave #collapsible well alone

from #1852104-0

The HTML5 spec says that details are always collapsible.

We don't need it why not remove it.

nod_’s picture

And the point of the whole details thing was to address the fact that fieldset are overused and often misused — insert semantic argument from previous details issues — and that changing the default to closed would highlight that and there are things details are not really suited for and a uncollapsible fieldset should be used (and we can see from tim's feedback that some places would do better without the ability to be collapsible).

Defaulting to false would make contrib think about that, because it is not possible to have details element not collapsible, making sure they see it's collapse will make sure they don't miss that detail and fill bug reports about chrome not being able to not collapse details elements.

I think that's how the argument should go.

elachlan’s picture

Issue tags: +Needs change record

Now that it is not defaulting to open with details. What should we use for the old fieldsets that were set to be always open?

What ever we are supposed to use the documentation should be updated to reflect that.

https://drupal.org/node/1852020

xjm’s picture

Title: #type details: Rename #collapsed to #open » [Followup & change notification update] #type details: Rename #collapsed to #open
Priority: Normal » Critical

In general, we should either revert patches when there's a significant regression, or open separate followup issues where there's not, to avoid the confusion and staring. :) Too late for that here, so retitling for clarity, and bumping priority appropriately for #36.

tim.plunkett’s picture

Title: [Followup & change notification update] #type details: Rename #collapsed to #open » #type details: Rename #collapsed to #open
Priority: Critical » Normal
Issue tags: -API clean-up, -Needs change record +API change

Hm? This was reverted, see #25

xjm’s picture

Thanks @tim.plunkett, missed the post-on-behalf-of-committer. :)

nod_’s picture

sun’s picture

The default is collapsed, because HTML5 details elements are collapsed by default.

Details elements are only expanded, if you add the additional open attribute. That is not the default.

HTML elements generated by Drupal should follow the default semantics of standard HTML elements.

In addition, as @Bojhan already mentioned in #30, the construct of "collapsible fieldsets" was intentionally replaced with native details elements. Not only because they're shiny HTML5, but also because the name "details" alone encompasses everything everyone needs to know: Details. Not Collapsible Whatnot™. Just Details. Details are not part of the 80% use-case. It is illogical to assume that details would be expanded by default.

tim.plunkett’s picture

I don't disagree with making that the default. But the previous patch did not preserve the (possibly incorrect) behavior of core.

If someone goes through and adds '#open' => TRUE to every place that has no specified #collapsed while doing the conversion, I'm happy.

nod_’s picture

reroll taking care of #42.

jibran’s picture

Status: Needs review » Needs work

includes/form.inc:2935: * Properties used: #attributes, #children, #collapsed, #description, #id,
This doc block needs update.

/**
 * Returns HTML for a details form element and its children.
 *
 * @param $variables
 *   An associative array containing:
 *   - element: An associative array containing the properties of the element.
 *     Properties used: #attributes, #children, #collapsed, #description, #id,
 *     #title, #value.
 *
 * @ingroup themeable
 */
function theme_details($variables) {
nod_’s picture

Status: Needs work » Needs review
FileSize
78.48 KB

thanks, fixed

sun’s picture

The patch generally looks good, but I do not understand why we're adding '#open' => TRUE to so many details.

1. How many of those belong to vertical tabs or collapsibles/accordions? All of those should not be open by default, because the wrapping vertical tabs or accordions presentation can be replaced with a different or be removed altogether — also, their pre-render process automatically applies the right details + container properties to make them work for the respective visual interface component. In other words, if you temporarily comment out the library definition of vertical tabs and collapsibles/accordions, then you should see a list of regular details elements that are closed by default. Therefore, #open should not be declared on those.

2. According to what's visible in the diff context, another small portion seems to related to details elements that additionally have a .container-inline class — which is a combination that is very strange to begin with. All of these details elements should probably be changed to simple fieldsets.

3. The previous two points probably cover 80% of the details for which #open was added. The remaining ones can probably be left for a follow-up issue.

nod_’s picture

Issue tags: +Drupal wtf
FileSize
71.67 KB

reroll.

I'm done with this patch, someone take care of it and get rid of a big Drupal-WTF please.

berdyshev’s picture

Status: Needs review » Reviewed & tested by the community

looks good for me

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Novice

#48 we at least need a reason provided that this rtbc quality and can disregard @sun's comments in #46.

tkoleary’s picture

@sun

3. The previous two points probably cover 80% of the details for which #open was added. The remaining ones can probably be left for a follow-up issue.

#2018871: Make summary and details collapsed by default which Nod was going to mark as a dupe is essentially the follow up. It offers a logical approach to determining what details wrappers in core should have #open and a list of them.

chanderbhushan’s picture

Status: Needs review » Needs work

The last submitted patch, 47: core-details-open-attr-1892182-47.patch, failed testing.

chanderbhushan’s picture

Issue summary: View changes

Applied the patch comment #47, but its not working locally for me.

nod_’s picture

be more specific please. what and where it's not working?

wundo’s picture

Assigned: Unassigned » wundo
sun’s picture

Assigned: wundo » Unassigned
Parent issue: » #1168246: Freedom For Fieldsets! Long Live The DETAILS.
sun’s picture

Assigned: Unassigned » sun
Priority: Normal » Major
Status: Needs work » Needs review
Issue tags: +beta target
FileSize
73.92 KB

Re-rolled against HEAD.

I super-carefully reviewed + validated every single change in this patch, and converted all new instances of #type details in HEAD.

Attached patch should be 100% correct. Interdiff wasn't possible unfortunately, since the existing patch no longer applies.

Would be great to get this in ASAP, because this is even more painful to re-roll + re-validate than the libraries.yml patch... :-/

fietserwin’s picture

  1. +++ b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php
    @@ -293,8 +293,7 @@ protected function buildConfigForm(Element $schema, $config_data, $base_config_d
    -            '#collapsed' => $collapsed,
    +            '#open' => !$collapsed,
    

    Should we rename this parameter to $open (including reversing it meaning of course)? Follow-up or in this patch: I found 2 usages, 1 of which was using the default, the other passes in a hardcoded TRUE, so the patch would only get 2 more 1-line changes (function definition line and 1 invocation line).

  2. +++ b/core/modules/simpletest/simpletest.theme.inc
    @@ -125,7 +125,7 @@ function theme_simpletest_test_table($variables) {
    -      $rows[] = array('data' => $row, 'class' => array($test_class . '-test', ($collapsed ? 'js-hide' : '')));
    +      $rows[] = array('data' => $row, 'class' => array($test_class . '-test', ($open ? 'js-hide' : '')));
         }
    

    Should this be: $open ? '' : 'js-hide'

Assuming that @sun indeed super-carefully reviewed each change, I did not look for missed #detail elements in the Drupal core code base, I believe @sun.

I like the removal of unnecessary brackets, though 1 case was missed, but that is not a problem at all. If the 2nd point is an error this is NW and point 1 could be taken into account as well for the new patch. If point 2 is not an error, point 1 is not important enough to hold this patch, so then it is RTBC for me.

sun’s picture

FileSize
73.92 KB
717 bytes

Thanks, @fietserwin - well spotted!

I've to admit that I did not intensively review that particular change, because it's JS related and thus I assumed that @nod_ would have done so already ;-)

But yeah, that's the exact reason for why I do not want to rename that other $collapsed variable in the config_translation module here :-) That can be a trivial/novice follow-up issue.

fietserwin’s picture

RTBC for me, but needs manual testing according to one of the tags, which I didn't do.

joelpittet’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Needs a re-roll.

Checking patch core/includes/form.inc...
error: while searching for:

// Collapsible details.
$element['#attached']['library'][] = array('system', 'drupal.collapse');
if (empty($element['#collapsed'])) {
$element['#attributes']['open'] = 'open';
}

error: patch failed: core/includes/form.inc:2063
error: core/includes/form.inc: patch does not apply

sun’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
73.92 KB

Simple diff context conflict. No interdiff.

Please note that I'm only able to guarantee a correct conversion of details elements for the state of core/HEAD on February 23, 2014. Any details elements introduced after this date are not covered, because it means hours of work to find all instances and double-check whether a particular instance has been converted already or not.

I actually do not think that this needs extensive manual testing, aside from a quick verification of some samples throughout core. In case there will be any regressions, it will be much easier to fix them in a quick/novice follow-up patch.

Draft change notice: https://drupal.org/node/2204131

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs manual testing

@sun thanks for the re-roll.

I went through and the diff looks very thorough. Gave it a simple test manual test. There looks like there are regressions for a couple collapsible fieldsets that haven't been converted but not due to this patch and if anything this patch helps that a bit in a couple cases. I think this is ready to go and cleans up the collapsible/collapsed/open intermediate stage greatly.

RTBC IMO.

fietserwin’s picture

#63: Perhaps it would be better to list these cases that you found during testing and perhaps even already create a follow-up for it. This might make acceptance of this patch easier.

joelpittet’s picture

@fietserwin good call, because I'll likely forget:S

On the install screen during simplytest.me install using 8-alpha8 vs 8.x + patch.
This one stood out:

sun’s picture

That's a different bug and not caused by this patch — see #2193271: Remove default #size attribute from core

That particular page of the installer does not use details elements anymore.

joelpittet’s picture

Great saves opening a duplicate:)

webchick’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +Approved API change, +Needs followup

Since the W3C defines this attribute as "open" it makes sense we would call it that in our code, too. Adding the "Approved API change" tag here. It does create a bit of a problem though that #type => fieldset doesn't match, so unfortunately we probably need another major task / API change to switch that one, too. Adding "needs followup" tag for that.

Patch still applies, so getting it in while it's hot.

Committed and pushed to 8.x. Thanks!

sun’s picture

@webchick:

It does create a bit of a problem though that #type => fieldset doesn't match, so unfortunately we probably need another major task / API change to switch that one, too.

Not sure I understand what you mean — #type fieldset no longer supports #collapsible and #collapsed in D8 at all?

That was removed in #1852104: #type details: Remove #collapsible property already, because the entire concept of "collapsible fieldsets" is gone.

sun’s picture

Sorry, wrong issue link — that concept was removed in the original #1168246: Freedom For Fieldsets! Long Live The DETAILS.

webchick’s picture

LOL oh. Well nevermind then. ;) Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

wdev’s picture

function hook_field_group_form_process_build_alter(array &$element, FormStateInterface $form_state, &$complete_form) {
      $node = $form_state->getFormObject()->getEntity();
      if ($node->hasField('field_pub_date') && !$node->get('field_pub_date')->isEmpty()) {
        $element['field_pub_date']['#attributes']['open'] = TRUE;
      }
}
wdev’s picture