In a number of places we are creating links with an empty href from JS, for JS. This should be replaced with button elements since this is what they were designed for. Links should always go somewhere.
See: http://stackoverflow.com/questions/10510191/valid-to-use-a-anchor-tag-wi...
CSS can take care of styling buttons properly.
Files that needs changing: collapse, machine-name, tabledrag, vertical-tabs, contextual, text.
Comment | File | Size | Author |
---|---|---|---|
#81 | core-js-button-1719640-81.patch | 6.71 KB | nod_ |
#78 | core-js-button-1719640-78.patch | 6.68 KB | nod_ |
#72 | core-js-button-1719640-72.patch | 7.35 KB | SebCorbin |
#72 | interdiff.txt | 483 bytes | SebCorbin |
#64 | core-js-button-1719640-64.patch | 7.35 KB | nod_ |
Comments
Comment #1
nod_this tag too.
Comment #2
nod_Some CSS is still wonky.
Comment #3
tim.plunkettComment #5
droplet CreditAttribution: droplet commentedIt looks semantic incorrect. I'm considering few points:
1. Although BUTTON can placed everywhere, mostly (I) think it is a form element and should be inside the form and act form behavior.
2. href can be omitted in HTML5, as a placeholder
3. div inside the tag is invalid
vtabs is bad for seo and UX. it should use #anchor point to fieldset. and active the tab when users navigate with example.com/#show-vtab
machine name, point to input #id?
tabledrag handle , I think it's absolutely don't need any button or a tag.
Comment #6
nod_1) That is actually in favor of the change. Except for contextual links, in core, in all other cases, the button (and links currently) are inside of a form. Let's use form controls to do forms-things.
2) Yep, placeholder. This is no placeholder. What the spec says: "If the a element has no href attribute, then the element represents a placeholder for where a link might otherwise have been placed, if it had been relevant." But we are using them they, are relevant (not as link but just as "something that can be clicked").
3) yep, that's only for tabledrag though. Wich is a mess in itself. Happy to drop the change for this one.
About vTabs: I agree very much. If we change it like that, happy to drop the change for this one too.
machine name: no because the field is hidden. It makes sense for tabs, not so much here.
tabledrag, Yeah sounds like it could do without. That's very old code though, who know why it's in there.
Try the change in Opera, it's so much better with buttons instead of links. I can finally only use tab to edit the machine name of a field.
Reroll, since I removed the tabledrag and vtab thing, there is no more theming issues as far as I can tell.
Comment #7
Kiphaas7 CreditAttribution: Kiphaas7 commentedJust some random thoughts:
- Shouldn't this get both a quick accessibility and usability review?
- Is seven the only theme affected? Bartik can be used for admin tasks as well?
- regarding the tabledrag discussion: Maybe that got introduced here http://drupal.org/node/448292?page=1#comment-3107944
Comment #8
sunClarifying title and correcting the category.
I agree with #5
Such styles commonly mean that some element is abused to do what another element is supposed to do.
This essentially reminds of our weird styling for collapsible fieldsets, which completely abuses the original/actual purpose of fieldsets. (see #1168246: Freedom For Fieldsets! Long Live The DETAILS.)
In this case, the abuse is much clearer, since the styles are lightweight and even the comment clearly states that it is restyling one element to pretend and appear to be another one.
-1 on the idea of abusing buttons for links.
Improving the link URL fragments/hashes where possible looks sensible though.
Comment #9
Everett Zufelt CreditAttribution: Everett Zufelt commentedNeeds review, but I don't have time.
- Must still be functional w/ keyboard only
- Must show visual indicator when focused
- Must be accessible with screen-readers
- Semantics must be intuitive, as they drive screen-reader user's perception of functionality (textual affordance)
Comment #10
nod_well, using button would improve all of that. links shouldn't have been used for this to begin with. and yes the ui is still showing all the relevant states.
I only changed the style to not change the ux. I personally don't care that it looks like a button. that's not a great argument to raise against a semantic change.
it's links that are abused as button here not the other way around.
Comment #11
Everett Zufelt CreditAttribution: Everett Zufelt commentedSounds like it passes the first two points, now just needs some screen-reader testing. Perhaps VO + Safari on Lion and VoiceOver or JAWS on FF or IE
Comment #12
Kiphaas7 CreditAttribution: Kiphaas7 commentedThis issue didn't really gave me any pointers on why a button should be preferred over a hyperlink. So I went googling, and this actually made sense to me:
http://stackoverflow.com/questions/10510191/valid-to-use-a-anchor-tag-wi...
Comment #13
nod_Thanks for finding that, Added to OP.
(edit) @sun: look in the seven styles.css, there are
a.button
rules. I'm working on a reroll to show buttons as buttons.Comment #14
nod_Here it is, I'm pretty sure we can take out all the a.button rules but don't have time to look to much into it. Seems ok though.
I left out the collapsible file since it'll be taken care of in the other issue.
Was able to do some nice html/CSS/JS cleanup :)
The new patch should really help with discoverability of the edit and summary buttons, it's clear what they do now.
Comment #15
LoMo CreditAttribution: LoMo commentedLooks good. Attaching screenshots for review.
Before patch
After patch
(content type / field admin page)
node/add/xxxx show/hide summary buttons
Comment #16
BarisW CreditAttribution: BarisW commentedLooks good!
I'm not sure about the distinction between the use of a button or a link. You say "Links should always go somewhere.", however I always thought that links should be used for navigation and not for actions? So for example a page like this (screenshot); shouldn't all those links be buttons?
I think the visual aid should be "am I doing something?" (button) or am "I browsing somewhere?" (link), whether this action is trigger on a new page or via Javascript shouldn't be relevant to the end user.
Same with the 'Local Actions' (+ Add block), shouldn't that be buttons too?
Food for thoughts?
Comment #17
BarisW CreditAttribution: BarisW commentedForgot screenshot.
Comment #18
Kiphaas7 CreditAttribution: Kiphaas7 commented#17, How about this:
Button: do something on this page (or do something which requires a submit/refresh, but always automatically go back to this page).
Link: take me to a different page.
In this case:
If you define it as actions it becomes tricky: basically everything in the administrative overview is an action in some way... Hell, even going to a new section is an action. Everything you do is an action :).
I'd call it "actions on the same page". The rest should be
<a>
Comment #19
nod_I'm not trying to replace more, just what's on the #15. If it's created in JS it should probably be a button, that's it.
Comment #20
mgiffordI tested admin/structure/types/manage/article/fields for keyboard functionality. That seems to work fine.
Going back to #9 from @everett this still leaves:
- Testing with screen-readers (JAWS, VoiceOver, NVDA)
- Must show visual indicator when focused (this issue needs to be re-opened generally, previous effort in D7 #418306: Adding Visual Focus to Form Elements)
- Add semantics with ARIA -- roles role="button" aria-pressed="true" http://yaccessibilityblog.com/library/easy-fixes-to-common-accessibility...
Comment #21
Bojhan CreditAttribution: Bojhan commentedI really don't understand this, the markup cleanup pretty much removes a usability feature?
I understand there is confusion that we from a markup sense apply the wrong element, but the feature that we have buttons that appear as links is still valid. We are long past an era, where users only understand buttons as buttons and links as links - testing has proved over and over again that this link pattern works. We use it for buttons that have a highly "decreased" importance.
I fully understand the need to fix the markup, but I do not agree with changing the styling to remove this usability feature and create aesthetic imbalance on a large number of pages.
Comment #22
Everett Zufelt CreditAttribution: Everett Zufelt commentedAFAIK, aria-pressed is only required if a button is in a 'pressed' state (e.g. toggle button)
Comment #23
mgiffordI didn't find an example where the pressed state should be pressed. Not sure if this does anything for empty links either.
So at the least this needs to be re-titled.
Comment #24
Everett Zufelt CreditAttribution: Everett Zufelt commentedProvided that the markup is either button or link, and that the explicit aria role matches the visual design, I don't foresee any accessibility problems.
Comment #25
nod_Thanks a lot for the feedback.
Reading the aria doc it still make sense to keep a button as button, not using the link role on button.
http://www.w3.org/TR/wai-aria/roles#button
http://www.w3.org/TR/wai-aria/roles#link
Comment #26
Kiphaas7 CreditAttribution: Kiphaas7 commentedSo just to summarize some previous points brought up earlier and which seem to be unresolved so far (and please correct me if I'm wrong!!!!!):
Regarding the aria-role: isn't this what this topic is all about? Links added via js have the behavior of a button, but the looks of a link. If we make them semantically buttons, we don't need to add an aria role saying that they are semantically a link?
How they look shouldn't have anything to do with the aria role?
Comment #27
mgiffordIt will when it comes to writing up the patch.
However, it's secondary to defining how it should look.
Comment #28
Everett Zufelt CreditAttribution: Everett Zufelt commentedThings like vtab buttons, if made a button not an anchor, might be a bit clunky to get the (selected tab) text associated with. The text has to be set in the innerhtml of the anchor now, but cannot be set as a hidden part of the value of the button.
Comment #29
nod_vtabs are not changed by the patch and it's not planned to, they are linked to their fieldset with the id (well, not ATM but someone needs to have patch for that :),
I'm only concerned about what's on the screenshots.
Comment #30
Bojhan CreditAttribution: Bojhan commentedSo, yhea my review is above.
Comment #31
sunI'm warming up to this idea.
However, we need to (heavily) restyle these buttons to appear like links and visually clarify that they are triggering pure user interface actions on the same page, which do not involve concepts such as submitting data to anywhere or leaving the page.
The buttons also take up a lot more visual space than the links, which increases their importance, although their intended importance is very/super low. E.g., the "Show weights" button is way too distracting; the machine name "Edit" link is equally optional.
Especially the machine name
[ Edit ]
link was added to D7 and attempted to introduce a special.admin-link
styling for quick UI action links. The goal was to provide a visual pattern that allows to put an action widget along with text output right next to it (i.e.,Machine name: foo_bar [ Edit ]
), having both the text and the link appear in one visual line and size. AFAIK, in particular this pattern was taken up by a couple of contributed modules for exposing similar links.Comment #32
nod_Umm, so tried a couple of things, but first:
That means it's not a problem we can solve with either Bojhan or me happy :p I'd think that the role attribute would make the following possible since semantic and presentation are supposed to be separated by now :)
So I tried to use
<a role="button" />
to make everyone happy, BUT without href, it takes the button out of tabindex so it's just not possible to access it with keyboard. Putting an irrelevant URL as href is the exact reason why I started this patch so that's not a solution either.I still think we should go for button. Styled as links or not, that's just a few lines of CSS.
Comment #33
nod_oups
Comment #34
nod_reroll, using buttons that looks like links.
Comment #35
sunI think everyone is OK with this if we're able to fully retain the visual appearance, which is probably possible. (I especially care about the details outlined in #31)
Let's use modern selectors; i.e.,
button[role=link]
(that said, not sure whether that's over-specified; I guess that [role=link] could easily lead to false-positives)
Comment #36
Kiphaas7 CreditAttribution: Kiphaas7 commented#35:
IE8 supports it, so big +1 from me! Removing the class should also clean up the markup a bit (double +1). I'd support using
button[role=link]
for reasons you mentioned.Reference:
http://kimblim.dk/css-tests/selectors/
Comment #37
nod_Title is not descriptive enough.
I'm feeling strongly about this.
Comment #38
nod_used button[role=link] and added the role attribute where needed.
Comment #39
Kiphaas7 CreditAttribution: Kiphaas7 commentedLooks fine to me, so +1 for RTBC from my side.
Comment #40
Bojhan CreditAttribution: Bojhan commented#21 has never been addressed, so this is not RTBC at all.
Comment #41
nod_With this patch they look like links.
Comment #42
crobinson CreditAttribution: crobinson commentedRelated, but not a duplicate (providing this here for convenience):
http://drupal.org/node/1342066
Comment #43
nod_reroll to have tableresponsive.js changed too.
I've added the correct id to links for vertical tabs and collapsible fieldsets it will now be a link to the proper ID. No problem leaving them as links with that.
I've talked with Bojhan a few days ago and he was ok with the patch since it still looks like links.
Comment #45
nod_Unrelated failure, patch is only changing CSS and JS files.
Comment #46
nod_#43: core-js-button-1719640-43.patch queued for re-testing.
Comment #47
nod_Comment #48
Bojhan CreditAttribution: Bojhan commentedIt worked for me, and didn't change anything visual. Since #39 I am gonna mark this RTBC
Comment #49
droplet CreditAttribution: droplet commentedcan we add a quote to every attribute selectors ?
foo[type="bar"]
seems like missing font declaration in *seven* theme. it needs "font-family: inherit;" or specified fonts
remove spacing problem in FF.
<button type="button" role="link">
Does it a button or a link ?
Comment #50
Kiphaas7 CreditAttribution: Kiphaas7 commented<button type="button|submit|reset">
The button is a clickable button, and does nothing related to submitting or resetting a form. Therefore
type="button"
. But it is styled to look like a link (see earlier comments why): for consistency regarding accessibilityrole="link"
is added.Comment #51
Bojhan CreditAttribution: Bojhan commentedInteresting I didnt know we are breaking with font-styling, that clearly needs to be fixed.
Comment #52
Damien Tournoud CreditAttribution: Damien Tournoud commentedSemantically, I'm not very fan of the idea.
<button>
is a form-associated element, so you would expect it to be... associated to a form. The MDC page for<button>
for example, specifies (emphasis mine):Looking at HTML5 itself, the constraint seems to have been lifted. HTML5 defines a "form-associated element" as (emphasis mine):
I would recommend standardizing on:
By the way,
<button type="button" role="link">
is *just wrong* anyway. The definitions of the roles according to ARIA are:role=button
:role=link
:ARIA even adds:
Using
role="link"
for pure styling purposes is an abuse of the role marker.Comment #53
nod_I'd rather quote the spec instead of the MDN implementation/interpretation: http://developers.whatwg.org/the-button-element.html#the-button-element
As you said, it doesn't need to be in a form. It can still be a submit button outside of the form it's submitting. Now if you look closer, all uses of button in core with this patch are inside of a form. That argument doesn't hold much ground in this case.
I'm really not hung up on using
role="link"
, I was going for a class to begin with and adapted based on feedback. Happy to fall back to using a class, the only issue Bojhan had with it was the look.Looking at the spec for the a element:
I'm sorry but a link with only "#" and that isn't meant to scroll back to the top of the page is plain wrong. And not putting a href removes the link from the tabindex, that makes it useless for us.
Button semantically makes sense. It also improve usability of those form elements on Opera, not that I expect much people to care even if I do.
Comment #54
danillonunes CreditAttribution: danillonunes commentedI give a +1 to this issue because I hate
<a href="#">
with passion. But I still concerned by two things about it:- I don't think majority of themers will replicate link styles to our "link buttons". This not gonna happen, unless there is a button slapping in their faces. Otherwise they will find some time later that "that obscure 'cancel' link just start looking like a button in my custom theme. WTF?".
I don't think this is critical, because we can count that base themes widely used like Zen can implement a link styles to buttons. But we should be aware about it anyway (i.e. we can't count that every link-styled-button will always look like a link just because that's what we do - so we should avoid texts link "click the link below to edit the machine name").
- Also, if we're styling buttons as links, it's important that we provide also, at least for default themes, styles for normal buttons to look like buttons, since that's what third party code expects buttons to be. If I put a Twitter box in my site, it probably will use as a button. I didn't look at the final result, so sorry if this is already addressed.
Also I agree with going back to
class="link"
instead ofrole="link"
. The role is clearly a button, that's why this issue exists in the first place.Comment #55
Robin Millette CreditAttribution: Robin Millette commentedThere have been plenty of comments already, many referring to standards. I would just like to note that Links make it easy to open a page in another tab, another window, whereas Buttons don't provide that flexibility. And sometimes that makes the most sense, as in this case I think, since we're triggerring something javascript and it hardly makes sense to open another browser tab/window.
Comment #56
Damien Tournoud CreditAttribution: Damien Tournoud commentedAs I mentioned on IRC, if we want to standardize on
<button>
I would rather see<button type="button" class="link">
then:<button type="button" role="link">
. Those are *not* links, but buttons visually styled as links (which is kind of wrong too).Comment #57
nod_Reroll with class, should fix the font issue as well.
Comment #58
droplet CreditAttribution: droplet commented- fix seven font in FF
- fix button padding in FF
Before:
after:
Comment #59
sunMissing type=button.
We always need that to prevent a button from being misinterpreted as a form submit button (type=submit is the default).
Can't we merge this into
button.link
and simply say?
Hm. I don't know off-hand what the exact rules for system.theme.css are, but if we need that FF fix in all themes, we should consider to move it into system.theme.css?
Aside from these issues, this looks good to go. So let's get those last bits quickly done and resolve this issue.
Regarding final tests, I'd like to request before/after screenshots for:
1) Stark, Bartik, Seven
2) I'd also like to see + confirm that the machine name widget still looks and works as expected.
Lastly, there are a couple of possible follow-up improvements that could be investigated after this has landed:
- Consider adding a new render #type for link buttons?
- Convert confirmation form "Cancel" links to link buttons?
- Convert "Delete" form buttons to link buttons?
- Investigate conversion of span.admin-link pattern to the new link buttons (used by machine name)
Comment #60
Wim LeersThe patch no longer applied. Rerolled.
- Added the missing
type="button"
as noted by @sun.- The
-moz-focus-inner
issue @sun noted is no more, thanks to normalize.css, which includes it (added in #723392: Tame seven's reset.css, and deleted seven's reset.css). Hence the changes to reset.css are no more; but this does not show up in the interdiff because the patch above didn't apply anymore.Testing: machine name works fine, collapsible fields too, as does the "Show weights" table drag button and the "Edit summary". Everything still looks identical.
I agree that this can be useful, especially if we want contrib to use this too. Secondly, we should then also provide
Drupal.theme.linkButton()
(or whatever the appropriate name would be), which would have helped prevent the missingtype="button"
in the first place.These sound sensible to me.
Comment #61
sunWe should keep these styles, regardless of this issue. Styling links as buttons is a perfectly legit use-case that should be retained, regardless of how our JavaScript wants to inject buttons.
Comment #62
nod_reroll keeping the a.button rules. I guess that'll be cleaned up in the buttons follow-ups.
Comment #63
Wim LeersHuh? Why did you add these? See my comment at #60.
Other than that, this looks good to go?
Comment #64
nod_Removed the CSS rules and rerolled because of the fieldset to details change.
Comment #65
Wim LeersWhat do we need here to get to RTBC? A final sign-off from sun or Damien Tournoud?
Comment #66
nod_I guess it's missing the screenshots sun requested.
Comment #67
droplet CreditAttribution: droplet commentedFound a little bug, for keyboard users, missing tab focus styles.
Comment #68
nod_Umm I see the :focus rule for link class and the buttons are underlined when I tab to them. Where and which theme is that happening in?
And also, just today: http://www.nczonline.net/blog/2013/01/29/you-cant-create-a-button/
Comment #69
droplet CreditAttribution: droplet commentedhmm. Seven ?
Edit summary
missing link:focus.
shouldn't it move to system base style sheet?
Comment #70
nod_That's right.
Comment #71
droplet CreditAttribution: droplet commentedrel: http://www.nczonline.net/blog/2013/01/29/you-cant-create-a-button/
Ouch, I've done some more tests. and only FIREFOX has "focus styles" problem.
Comment #72
SebCorbin CreditAttribution: SebCorbin commentedKeep
Drupal.t('Hide summary')
as it will be toggled if no summary is set.I can't understand why we should move the CSS though, colors are proper to each theme, only placing properties like text-decoration in system theme could be relevant.
I found a little typo though, so rerolling.
This patch is part of the #1day1patch initiative.
Comment #73
andypostHey, maybe better to properly implement "button" element that rendered as submit now. There's a some issues asked for this #289240: There is no way to make a button element that can use the AJAX functionality #72855: form #type 'button' does not work as advertised - it's always a submit
This require only a small changes but bring more consistency in theme layer
Comment #74
mgifford#72: core-js-button-1719640-72.patch queued for re-testing.
Comment #76
droplet CreditAttribution: droplet commented#72: core-js-button-1719640-72.patch queued for re-testing.
Comment #78
nod_Reroll. Tested everything again. Only changes are because of contextual links (which are now using buttons as they should).
Comment #79
SebCorbin CreditAttribution: SebCorbin commented#78: core-js-button-1719640-78.patch queued for re-testing.
Comment #81
nod_Comment #82
mgiffordWhere should we go to test this? I'd have thought admin/people/roles but that doesn't seem to be it.
Looked in a few folks with firebug to seek out a reference to
<button>
but kept coming up blank.What's the best way to test this? I'd love to eliminate the empty links.
Comment #83
nod_Have a look at #15 the screenshots have the wrong styling but they do show where the changes are.
- The "hide/show row weight" button
- The "Edit summary" button
- The "edit" button on machine name links
Comment #84
LewisNymanTested on Chrome, Firefox, IE8, and iPad. Looking good
+1 RTBC
Comment #85
nod_All right then :) Thanks
Comment #86
andypostI still think we need to refactor 'button' core element to have no confusion and usage in follow-up issue
Comment #87
nod_what does that mean in term of actionable feedback?
Comment #88
webchickI can't quite parse that either, but it says follow-up, so I think we're good to go here.
Committed and pushed to 8.x. Thanks!
Hope this didn't break anything. ;)
Comment #89
mgiffordIt is really used all over the place. It's a great step ahead though not to use the empty links. Great work!
Thanks @nod_ these don't really cut the places where these changes are found, but I took a quick zip around after @webchick's commit.
node/add/article
admin/structure/block
admin/structure/contact/manage/feedback/fields
admin/structure/menu/manage/admin/edit
admin/structure/custom-blocks/manage/basic/fields
admin/structure/types/manage/article/fields
Comment #91
droplet CreditAttribution: droplet commentedSome ref / info worth to read:
http://www.nczonline.net/blog/2013/04/01/making-accessible-icon-buttons/
Comment #92
mgiffordThanks for the link. Definitely interesting.
It's different in a few places though aside from not using Font Awesome. This patch introduces buttons with Javascript, while the author is concerned with ensuring buttons are available with javascript disabled.
I think the a Drupal version of this would be something like
<button type="button"><span class="element-invisible">Email</span></button>
As I read the patch, these two lines will insert a blank button:
+ $table.before($('<button type="button" class="link tabledrag-toggle-weight"></button>')
+ this.$link = $('<button type="button" class="link tableresponsive-toggle"></button>')
In which case this could be improved to include text like the other buttons of this patch.
@droplet is that how you read this?
Comment #93
mgiffordGreat that this is fixed in D8, just adding this as a resource for folks who stumble across this thread in the future. Love Karl's quote here "if it looks like a button and acts like a button, what compelling reason is there to not just use a button?"
http://www.karlgroves.com/2013/05/14/links-are-not-buttons-neither-are-d...
Comment #93.0
mgiffordadd S.O. link