git commit -m 'Issue #2493957 by droplet, mgifford, eiriksm: Add summary and errors support to native HTML5 details tag'
Problem/Motivation
Summary and errors support are no longer added to native HTML5 details tag
Proposed resolution
- Add Summary & Error support to HTML5 native Details tag.
- Trigger Details tag to OPEN state on HTML5 validation failure.
Remaining tasks
- Review patch
(Patch should be tested in all major browsers, especially Chrome and Firefox)
Steps to Reproduce
A: Add summary to native details tag
- Enable Book module
- Add Book Page
- Edit the new page's outline and select `- Create a new book -`
- Add another book page and assign it to the newly created book
- View the child page's book
Current behavior: no description in the details tag
Intended Behavior: selected book title in the details tag
B: Open Details tag when an error is triggered
Note, the easiest way to recreate this issue is to install the field group module.
- Install the Field Group module
- Add a required field to the Basec Page content type
- Go to the `manage form display` tab for the Basic Page content type
- Add a new group of type Details
- Add the required field to the Details group
- Add a new Basic Page and fill out all required fields except the required field contained within the details group
- Try to save the content
Current behavior: The form fails to submit with no notification of the failure
Intended Behavior: The form fails to submit, opens the group containing the field that failed to validate, and pops up the error notification.
Remaining Follow Up
- Rename `collapse-processed` to more meaningful, eg: `collapse-polyfill` or `details-polyfill`
- Change `$('')` to a button tag
User interface changes
-
API changes
-
Comment | File | Size | Author |
---|---|---|---|
#76 | Screenshot from 2022-04-11 16-55-19.png | 49.76 KB | larowlan |
#60 | old-page-desc.png | 30.88 KB | wolffereast |
#60 | duplicate-desc.png | 47.88 KB | wolffereast |
#42 | after submit.png | 261.4 KB | nils.destoop |
#42 | before submit.png | 247.06 KB | nils.destoop |
Comments
Comment #5
mgiffordJust a late night re-roll.
Comment #7
droplet CreditAttribution: droplet commentedComment #8
droplet CreditAttribution: droplet commentedActually we have to keep it same styling.
Comment #9
droplet CreditAttribution: droplet commentedSorry. right patch here.
Comment #16
mgiffordWhat is the best way to test this?
I think I saw an extra (and empty) span here when looking at the summary/detail element /admin/appearance
Comment #17
droplet CreditAttribution: droplet commentedI remove a change to make it move forward and easier for review.
UPDATED SUMMARY for REVIEWS STEPS.
Comment #18
droplet CreditAttribution: droplet commentedComment #20
mgiffordAre you going to submit the "follow up issue to change `$('')` to button tag"?
Comment #21
droplet CreditAttribution: droplet commented@mgifford,
I will submit it after this issue.
Comment #22
YesCT CreditAttribution: YesCT commentedwill this address what was noticed in #2473947-14: Prefix form-item-* classes with js- ? And add those back in?
"I think the javascript for the advanced settings details were these
which I git bisected to find were removed in #1838114: Change node form’s vertical tabs into details elements"
Comment #23
droplet CreditAttribution: droplet commented@YesCT,
This patch will add Summary back to HTML Details tag. But in your screenshot, that's verticalTabs, it's always working.
Comment #25
droplet CreditAttribution: droplet commentedRerolled
Comment #26
mgiffordI still couldn't replicate this following your instructions. Where is this missing?
Should I see it if I diff a book page somewhere like /node/3/edit with/without the patch?
Also, have these two follow up issues been created:
- Follow up issue to rename `collapse-processed` to more meaningful, eg: `collapse-polyfill` or `details-polyfill`
- Follow up issue to change `$('')` to button tag
Comment #27
droplet CreditAttribution: droplet commented1. Add a book page (should be BOOK)
2. go to Outline eg. /node/1/outline ( change 1 to Book page node ID)
3. You should see `BOOK OUTLINE (XXXXX)` after patched.
Comment #28
mgiffordops.. wrong window.
Comment #29
mgiffordI opened up 2 windows with different versions in Simplytest.me:
Without
https://df9f8.ply.st/node/2/outline
With
https://df9fs.ply.st/node/2/outline
Can't see the difference.
Comment #30
droplet CreditAttribution: droplet commentedwhat do you see ? any screenshot ? caching ?
Comment #31
nod_Made a little change so that the toggle function is only used when the polyfill is involved, never called for native details. The previous patch did not update the aria state of the details element when using native details. Simplified it by clicking on the summary to open the details element, that way aria gets updated properly in both cases.
With this patch drupal summaries are back for native details. This should be major at least.
Comment #32
droplet CreditAttribution: droplet commentedthe change will make OPENED state to CLOSED. It's why I made it always TRUE.
Comment #33
nod_woops that's right. Added a condition to check for open state before triggering the click.
Comment #34
droplet CreditAttribution: droplet commentedOK. Mainly nod_ restore my changes in `toggle()` and trigger OPENED state in `invalidHandler()` directly. All looks good to me. Since most changes made by me. I will leave another one for final review.
Comment #35
nod_I did more review than patching
Comment #36
alexpottWhy is this necessary?
Comment #37
droplet CreditAttribution: droplet commentedto standardize the color
Comment #38
xjmThanks for the manual testing steps and screenshots! Here is how I tested this patch.
/node/add/book
, create a "Parent" book node. Under "Book outline", set the book to "Create new book". Save the node./node/add/page
, create a node that has a URL alias that does not start with a leading slash and try to save. In HEAD, it is not clear where the error is. With the patch, the URL alias element is expanded to show the error.However, regarding #36 and #37, I also could not find where the CSS was being applied. Can we remove that from the patch and possibly put it in a separate issue with steps to reproduce the color inconsistency?
Comment #39
droplet CreditAttribution: droplet commentedHave you test in firefox ? (the browsers doesn't support native details)
Comment #40
nod_Comment #41
nod_No indication of FF testing in #38. CSS needed for consistency, back to RTBC.
Comment #42
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedI tested this on firefox and chrome via fieldgroups.
In chrome everything is ok after patch: the group opens and the error is shown on the textfield.
In firefox, the group opens, but the error is shown on top of the screen.
before submit:
after trying to submit:
Comment #43
nod_Let's open a different bug for that one, not everyone uses fieldgroup module.
Comment #44
nod_Checked it out with fieldgroup but there is nothing we can do about it. Byproduct of our polyfill for the details element. I don't see how another polyfill would solve that either. It's the danger of having hidden required fields.
Comment #45
alexpottThis patch seems to be breaking something... I've tested this doing
in Firefox 43.0 (OS X) and the automatic opening on the details element when there is an error inside does not work. It works great on chrome 47.0.2526.106. Without this patch the situation is reversed??? Very weird.
Comment #46
andypostThis may need JS testing instead of manual
Comment #47
andypostThis may need JS testing instead of manual
Comment #48
andypostThis may need JS testing instead of manual
Comment #50
joelpittetGood call @andypost, we have a framework in core now so let's give it a try. Adding tag for JS testing.
Comment #53
dmsmidtIt seems this is already fixed in core here #2346773: Details form element should open when there are errors on child elements.
Please re-open if I'm wrong.
Comment #54
droplet CreditAttribution: droplet commentedThis is diff things and more. We do it in frontend, not backend.
Comment #55
dmsmidtThat it are two different approaches I agree on.
But at least it is partly fixed right?
"If there are errors on an element in a details element, that details element should be opened". That is fixed by the issue I mention, and is what is described in #38.
So the part about the summary only needs to be fixed? Is this still actual?
Comment #56
droplet CreditAttribution: droplet commentedNope.
#2346773: Details form element should open when there are errors on child elements is changed the HTML output. (All done in backend)
This issue is working on frontend when the frontend form validation is failed. (All done in frontend)
Both patches trying to do the same thing but on diff stages.
Comment #57
Torenware CreditAttribution: Torenware as a volunteer commentedDropping back the Novice status, since it looks like some coding will be needed here.
Comment #58
wolffereast CreditAttribution: wolffereast commentedBeginning Triage
Comment #59
wolffereast CreditAttribution: wolffereast commentedStill applies in 8.4.x.
I am seeing an oddity when the description is added to the book description. It is adding both the Book and the Parent Item to the description. Is this intended?
Comment #60
wolffereast CreditAttribution: wolffereast commentedComment #61
wolffereast CreditAttribution: wolffereast commentedComment #62
cilefen CreditAttribution: cilefen commented@wolffereast I am going over the issues analyzed at the Baltimore triage in order to assign credit. I would like to give you credit for the work done, but I can't tell whether or not all steps of the triage were completed by reading the comments. We like to see documented steps (even if brief). Here are some made-up examples of documented triage steps:
Thank you!
Comment #63
wolffereast CreditAttribution: wolffereast commented@cilafen Sorry about that!
The issue still exists.
Updated the issue summary with additional steps to reproduce.
Found a related issue in the queue, though it is not an exact duplicate so I'm not comfortable marking either as closed.
Comment #64
dmsmidt@wolffereast, #2848507: Indicate that grouping elements have child element errors for ux and a11y is no duplicate. However when that gets in, it would be nice that the client side HTML5 validation logic could also take care of the parent grouping element (details).
Comment #65
droplet CreditAttribution: droplet commented#60 is slightly out of this issue scope.
Comment #72
nod_let's take the summary in the other issue and focus this one on the error part.
Comment #76
larowlanThis came up on the bug smash triage, looking at the latest patch it was 7 years ago, before we had es6.
However, after manual testing per the steps to reproduce, it no longer occurs