Problem/Motivation
The current markup for Dropbutton looks like this:
<div class="dropbutton-wrapper dropbutton-processed dropbutton-multiple">
<div class="dropbutton-widget">
<ul class="dropbutton">
<li class="edit dropbutton-action"><a href="/admin/structure/views/view/content">Edit</a></li>
<li class="dropbutton-toggle"><button type="button"><span class="dropbutton-arrow"><span class="visually-hidden">List additional actions</span></span></button></li>
<li class="clone dropbutton-action secondary-action"><a href="/admin/structure/views/view/content/clone">Clone</a></li>
<li class="disable dropbutton-action secondary-action"><a href="/admin/structure/views/view/content/disable?token=hQ2egsGF5LtsScdw2oQFeoWNKrUi1HHP9W1WZhjehOk" class="use-ajax ajax-processed">Disable</a></li>
<li class="delete dropbutton-action secondary-action"><a href="/admin/structure/views/view/content/delete">Delete</a></li>
</ul>
</div>
</div>
There's a lot we could do we simplify and improve the markup so it's inline with our CSS coding standards
Proposed resolution
<div class="dropbutton dropbutton--modifier"> <!-- whole component is dropbutton. -->
<a class="button dropbutton__action">Action One</a>
<button type="button" class="button dropbutton__trigger">
<span class="visually-hidden">List additional actions</span>
</button>
<ul class="dropbutton__menu" role="menu">
<li><a class="dropbutton__action">Action Two</a></li>
<li><a class="dropbutton__action">Action Three</a></li>
</ul>
</div>
Remaining tasks
Decide on a battle plan of improvements
Write a patch
Test a lot
User interface changes
None
API changes
Mark up changes
Comments
Comment #1
lewisnymanI've updated the summary with the blue sky markup:
Comment #2
nod_No empty
<a>. Parts of the code has been for JS reasons, can't remember which ones yet but expect to run into troubles with just this markup.Comment #3
tim.plunkettThe proposed markup seems to be a a11y regression.
Comment #4
mgiffordAny reason why we can't use the span in the trigger -
<span class="visually-hidden">List additional actions</span>It's way cleaner code which is great. If it is a button, shouldn't it semantically be defined that way? https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Tec...
Comment #5
adamjuran commentedComment #6
adamjuran commentedUpdating issue summary to add wrapper div for proposed solution.
My plan of attack:
* Add a dropbutton.html.twig file and associated preprocess. If single then only output a button, if multiple then a dropbutton.
* Rework css/js to get back to current UI.
* Test. A lot.
Comment #7
adamjuran commentedAdding more notes from my initial research.
Views UI generates markup in ViewsEditForm.php in two spots (function getDisplayDetails, function renderDisplayTop) and that needs to get updated. Ideally those two functions will call preRenderDropbutton() in Dropbutton.php so that dropbuttons are always generated in the same way.
Comment #8
droplet commentedCode self explanation. Cheers.
Comment #9
adamjuran commented@LewisNyman, what do you think of droplet's suggested markup?
Comment #10
lewisnymanI don't like the idea of added comments in mark up, because it will print with every dropbutton. I kind of hope that our CSS standards are clear so we know what a component is and isn't by the time Drupal 8 is out.
Comment #11
lewisnymanOk, I spoke to Adam properly about the issue. I think droplet's suggestions look good, updated the issue summary,
Comment #12
yesct commentedComment #13
lewisnymanComment #14
mortendk commentedI started the work of renaming the existing structure to a classname structure when during the banana clean up.
The real issue here is that dropbottom dont uses BEM & --modifiers, or prefixes the js required classes.
Getting those things fixed at first would be important win to get. We dont wanna end up in a situation with a component that will conflict with the css, as its the case now.
what we should look into is separating the classe so its clear whats used for "theme" so we dont use the js- prefixed classes for that all over.
Comment #15
mortendk commentedComment #16
mortendk commentedComment #18
droplet commentedjs-prefixed all elements. pretty bad idea.
Comment #19
mortendk commented@droplet about prefix how Else would You "protect" css classes that's only used for js?
we prefix classes that are needed for the js to work.
it's how it should be done according to our CSS docs in d8
Comment #20
lewisnymanA lot of the class changes here are simply swap child selectors for underscores, we have a suggestion in the issue summary for markup that makes more sense. A lot of the current classes don't have a lot of meaning. I don't know if it makes sense to add the
.js-prefix when those classes are added in Javascript?Can we have the dropbutton class as the wrapper class instead? So this class would be dropbutton--multiple
This should be using the a .is-open state class,.
We can simplify this to js-dropbutton__toggle-arrow instead and it becomes less dependant on markup structure
We can remove the .js-dropbutton classes from these selectors so they are shorter
This change has nothing to do with dropbutton, can we remove this?
Comment #21
lewisnymanTDLR, droplet is right, morten is wrong ;-) Sorry
The coding standards provide specific directions on this:
Which means, if we need a class for js functionality, we should use a new class that is only used for functionality, not just adapt the classes we use for styling. We shouldn't have any .js- prefixed classes in stylesheets.
Comment #22
mortendk commentedTDLR : seperate the css & js first, then play around with class names later.
@lewis well then how do you then propose we seperate the js from the css without using .js- ;)
We gotta get the seperation done first, if thats not done the rest dont matter, then were back in the same mess as d6, d7
So instead of this dance around classnames how about we start with getting the seperation done first
Rewriting everything with new markup etc, is a fine goal - but at RC-1 all markup is locked down.
Comment #23
lewisnymanWe just need to split it in to two classes. One that is functional, and one that is for styling.
Comment #24
mortendk commented@lewis ok so we turn this issue into doing that or do we still wanna rewrite it all ?
Comment #25
lewisnymanThis issue is about rewriting the Dropbutton markup inline with our CSS standards. If the patch doesn't match our CSS standards then it's not fixing this issue. The issue summary has the markup suggestion but I think it needs updating with the js- classes?.
Comment #26
adamjuran commentedI'm at Drupalcon LA and restarting work on this issue. Combining the original CSS classes from @lewis and the required "js-" classes from @morten leaves us with something like for an open dropbutton:
My plan of attack:
Comment #27
adamjuran commentedThis patch has all the new markup as well as JS and CSS changes.
Next steps:
Comment #28
lewisnymanComment #30
adamjuran commentedRebased against 8.0.x and found a JS error. Also cleaned up the CSS according Drupal standards, but for Bartik only at this point. Before I address the CSS changes for Seven and Classy I want to run testbot to track down what tests will need updating (xpath tests against CSS classes and when the classes change the tests too need to change).
Comment #31
lewisnymanComment #33
adamjuran commentedThis patch contains the following changes/additions from the previous one in 30.
Comment #35
adamjuran commentedThis patch contains:
Had trouble creating the interdiff this time. Sorry that it's missing.
Comment #37
adamjuran commentedRerolled patch, and got the interdiff too!
Comment #38
adamjuran commentedComment #40
adamjuran commentedThis patch contains:
Please note that even if this patch passes all tests it is NOT ready for review until the issue I raised in the 3rd bullet point is resolved.
Comment #42
adamjuran commentedOnly change is two spaces on line 160 of RowRenderCacheTest.php without which the assertEqual on line 165 fails.
Comment #43
rteijeiro commentedWell, it seems this still needs some work as you can see in the screenshots:
DROPDOWN BUTTON BEFORE
DROPDOWN BUTTON AFTER
Just fixed a couple of nits. I wonder what is the standard when using
[dir="rtl"], in some places there is a space after and in other places no.Comment #44
lewisnymanI think the first thing we need to do is decide how it should look in Stark and Classy. I assume that it should not apply anything on Stark. For Classy, I think that it should basically look as the Seven design but without colors. I think this fits with how Bartik was using Dropbutton before as well.
I would be good to get agreement from the Classy maintainers.
Comment #45
davidhernandezIs it possible to use data attributes for this? We really do want to get away from the js- prefixes. We're just using it as a last result of sorts to split the existing ones.
Yes. Stark should remain as close to browser defaults as possible.
Yes. I didn't pour over the CSS, but we are ok to have the structural stuff in Classy, but not colors and other styling. And so long as this is an agreed upon standard for how we want buttons or whatever to look for Drupal and the style guide. Not just the default place to dump stuff that Seven and Bartik use.
Comment #46
lewisnymanI thought about this a little more, Classy should have so minimal styles that Seven and Bartik shouldn't have to undo any styling to apply their design. I think that would be a sign that Classy is doing too much. Maybe a styleguide for Classy would make sense at some point.
Comment #47
lewisnymanI had a look through this patch and ended up changing a lot. This is my proposal for the Classy styling. I also ripped out the dropbutton--single/dropbutton--multiple stuff and now only apply the dropbutton class when there is more than one, otherwise apply a button class. Seven and Bartik don't look right but I want feedback on the Classy implementation first.
.
Comment #48
lewisnymanScreenshots:
Comment #53
adamjuran commentedWorking on a reroll for this, will also review Lewis' separation of styles between core and Classy.
Comment #54
adamjuran commentedRerolled patch.
Comment #57
adamjuran commentedLewis had changed the .dropbutton class to .js-dropbutton so I've fixed the tests to accommodate for that.
Comment #59
adamjuran commentedMissed two! Should be all set now...
Comment #60
adamjuran commentedComment #61
adamjuran commentedForgot to attach patch and interdiff for #59.
Comment #63
joelpittetJust a quick review:
Don't need this extra line at the end.
This looks like an @todo?
Does all of this need to be done here or can some of it be broken off to keep the patch easier to review?
Comment #64
lewisnymanFixed some of these comments here and realised there was still a lot of work to do. One final push before RC. Here are some screenshots from Classy, Bartik, and Seven.
Comment #67
nod_Interdiff doesn't work straight away so not uploading one.
Rmoved css file from core dropbutton library.
Removed leftover
</li>from js theme function.Simplified the JS, I don't like unwrap. It's more predictable now.
Added .dropbutton to all dropbuttons (not just the ones with a menu). This fixes problems with views ui.
Added the previously used .dropbutton-multiple on dropbuttons with menus (This class only adds the padding required).
Comment #72
nod_might as well go with a data attribute right now. rolling patch and fixing tests.
Comment #73
nod_got rid of js-dropbutton and used data-drupal-dropbutton as it should.
Things are still working on the frontend, let's see how much I broke tests.
Comment #76
davidhernandezNot sure this can be committed now. Markup and CSS is frozen after RC.
Comment #77
nod_Local tests take too long, sorry for the noise while I fix remaining test failures.
Comment #78
nod_Did some profiling, the new code is marginally faster.
Comment #81
emma.mariaAs we are now Post Drupal 8 release, can the future steps for this issue be laid out please?
ie. Looking at the code in the latest patch - what can still be used, what needs to go and where do we move things to?
We have bugs being raised based on contrib modules having dropbuttons with single values having no styles. This issue will solve that with the solo value = button markup.
#2700521: Dropbutton with a single option misses its rounded corners
Comment #86
andrewmacpherson commentedI found this after @lauriii pointed me at the parent issue, #1899236: Add new Splitbutton render element to eventually replace Dropbutton.
Over in #2893663: Dropbutton should report open/closed state to assistive technology I suggest we follow Menu Button pattern from the WAI-ARIA Authoring Practices.
I like the proposed markup here, it's much closer to the specimen code for the ARIA menu button pattern. Notably, the more-actions button is no longer nested inside the list which it controls, which was a bit weird currently.
I see there's a
role="menu"on the list. That's part of the ARIA Menu Button pattern, but adding that role alone won't suffice. There's also a need to manage roles on the descendent LI and A elements, as well as somearia-*properties on the button. Is this issue just about establishing the markup? The ARIA pattern calls for managingaria-expanded, which is a dynamic property.Comment #87
andrewmacpherson commentedminor title tweak for clarity.
Comment #90
geek-merlinThis should really be consolidated with the linked issue!
Comment #92
huzookaHere's my PoC-proposal for splitbuttons.
Instead of rewriting the existing Dropbutton, this patch provides a new element: Splitbutton. Now it allowed to contain "submit", "button" and "link" type children. It also tries to converts the dropbutton-legacy '#links' children (so if you want to test this, you only have to modify the existing dropbutton type from ['#type' => 'dropbutton'] to ['#type' => 'splitbutton']).
I also attached a patch for Paragraphs Classic widget that operates with the new splitbutton element.
The
splitbutton.jstries to be as accessible as possible (see #3067697-24: Dropbutton breaks when text is split to multiple lines).I haven't done any styling for Seven, Bartik or Claro (but I had to fix a nit for Claro's multiple value form).
Comment #94
huzookaComment #95
huzookaComment #97
huzookaComment #98
huzookaComment #99
adamjuran commented@huzooka @laurii is new styling required here or just simplified markup without breaking the existing styling?
Comment #100
andrewmacpherson commentedInteresting to see some movement here.
If this issue is leaving dropbutton alone, then I'll leave #2893663: Dropbutton should report open/closed state to assistive technology open. It's still a bug which ought to be addressed in dropbutton.
I'll dig out bookmarks, and read about this all again. Meanwhile, some of my thoughts were already noted in comments #10-13 of [#3892663-10].
If we remove the menu and menuitem roles, I don't think it will mean a big rewrite of the patch here, because those are just static properties. It could also mean we simplify the keydown handler (though I really like the look of that part of the patch).
Another possibility is to include an option, called
use_aria_menu_roleor something. If true, we layer more roles on. If false, it's just a list of links.The use of
aria-controlsandaria-expandedis the same either way.I had the idea that the standalone "action one" could be optional. If absent, there would still be a button which reveals a list of links. Currently layout builder depends on contextual links module, but there was some concern about whether that was the best choice, and if layout builder might use a different button for it's menus. This button might provide a basis for that.
Comment #101
huzookaRe #100:
Since we cannot change dropbutton for BC reasons (imho), the way to move on is:
So:
#100.1: Please, don't close #2893663: Dropbutton should report open/closed state to assistive technology.
#100.2: I'd continue with the new option
use_aria_menu_role. I'd set it to true by default, but if there is any button (or [input="submit"]) inside the dropdown, (or it's set to false), we don't add the roles.#100.3: Yes, yes, I want to do that. My plan was that I'd make SplitButton able to display more than one 'primary' item (that are displayed next to each one, outside of the dropdown). But if splitbutton would be able to have no primary items, it would be able to replace the contextual menu as well (where I mean the collapse/expand button and the contextual links dropdown).
Comment #102
huzookaComment #103
huzookaLet's have tons of failed test!
Only minimal CSS styles, no text rewrites, but the provided PoC addresses #100.2 and #100.3
I was able to replace the fake Views UI dropbutton mentioned in https://www.drupal.org/project/drupal/issues/1899236#summary-proposed-re... #1 with a Splitbutton.
#100.3 can be checked on Views UI's view edit form:
Comment #104
huzookaComment #105
huzookaComment #106
huzookaComment #107
huzookaSome progress...
Comment #108
huzookaUmami Splitbutton styles still have to be checked.
Comment #109
huzookaComment #110
huzookaComment #111
huzookaComment #112
huzookaComment #113
huzookaComment #114
huzookaComment #116
bnjmnmDuplicate of #1899236: Add new Splitbutton render element to eventually replace Dropbutton
Comment #117
rteijeiro commented