New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dealing with styling of "a" tags (with or without hrefs?) #142
Comments
IIRC @wesleycho changed it on uibs to not use an anchor at all. I am fine with option 1 and 2. |
Only cavaet of not using an anchor in UI BS is that I also had to add documentation where the styles from Bootstrap are mirrored so people can easily copy/paste it for their apps. I'm wary about the anchor tag due to the prior routing issues, and problems with nesting buttons under an anchor tag, which some users wanted to do. I toss my vote to using a |
I vaguely recall there were accessibility issues that arose when switching to |
Also, is it worth looking at what Material does? |
This is what we do at Thomson Reuters: |
@mendeza That's the pattern used in the angular-ui-bootstrap library as well.
It's the # in the href tag that causes problems. |
@RobJacobs Precisely - and there's simply no need for it. |
It sounds like we're going with leaving an empty |
We should check what happens wit new router and empty hrefs before closing. |
Empty hrefs are failing tests with:
|
So, my best idea for today is to use Thoughts? |
We will need to remove that in the future if we do that - it is a CSP violation. |
Oh man.... Indeed... |
If this a limited and specific use case such as the example shown at the outset, use a button instead of an anchor. Buttons are more mobile-friendly anyway. |
@mendeza there are going to be a few places in the library where we use the anchor tag and cannot use a button. E.g., tab headings. Additionally, styling a button as a link has some a11y ramifications. We'll need to figure this out somehow. (I haven't looked, but BS4 CSS may already handle this for tab headings...idk off the top of my head). |
OK, another idea. How about this:
To avoid pain of writing too much for prevent default we could use this trick: |
Can't say I love API that hides behavior like that, but it'll do for solving this problem. |
It makes me feel dirty as well.... but the big advantage is that it works :-) |
Bootstrap moved to classes purely in Bootstrap 4 I believe, and less selector opinionation. I believe anchor tags are better for accessibility in many situations, but I'd need to look into it. |
@wesleycho, some food for thought...
As an aside, I hope you guys are getting some rest. You've been going what seems like 24-hours a day. |
There are some advantages of having people in different time-zones :-) |
Hi everyone.
Keyboard users expect links to be activated with One would need to implement all the required keyboard events and provide the proper role ( @mendeza provides some great resources. Here is another very clear one from the last week: https://marcysutton.com/links-vs-buttons-in-modern-web-applications/ So if it does navigation and change the URL (with the exception of a form post and subsequent navigation) it should really be a properly formatted If it initiates a user action in the page it should be a Another thing to keep in mind is NOT to use buttons and style them as links or use links and style them as buttons as it can also lead to confusion (see Marcy Sutton's post mentioned above). |
@AlmeroSteyn If I'm reading you correctly the lesson from all this would be to use |
Hi @AlmeroSteyn, thanks for this. I do believe everyone here is aware that I totally agree with:
But I disagree that |
@pkozlowski-opensource If it is not linking to another resource by URL that is the way to go, IMO. @mendeza yes this is a bit of a gray area when looking online but the reason for that is that it can lead to confusion further down the line. From Marcy's post:
The style itself does not affect the core of how the browser or screen reader handles the element, but these kinds of soft issues can happen. |
Just had a look at the various components and it seems like we can replace |
@mendeza Yes, inside the app, by using proper descriptive text and things like Outside that we have little control over what users will do. So I think the takeaway is simply that using the tags as intended removes the issues without further effort (First rule of ARIA). But this remains an area that can be easier to discuss than to implement. NOTE: The example you show above is a big issue. An |
@AlmeroSteyn - agreed, but I was conceding the point that the BS4 team have punted on proper A11y for their carousel, thus it's arguable that it isn't the ng-bootstrap team's responsibility to fix. I haven't yet looked at the (to use @wesleycho's phrase) selector opinionation of the BS4 carousel, which one could imagine might defeat or make too onerous a fix by ng-bootstrap. My team wrote a new carousel that is accessible, at the expense of not leveraging BS4 CSS and adding custom code. |
@pkozlowski-opensource, might it be worth seeing what AM is doing here or reaching out to Kara or Jeremy to see what are doing or intend to do? W/r/t tab changing and using buttons, wiring in tab navigation to browser history is common and I think switching to buttons would break this, no? Or make it quite a bit more difficult to manage. Same with accordions. |
Due to the interesting discussion about semantic markup and A11y, the original question perhaps got a bit obscured; even if
So having a nice-enough pattern that people don't mind re-using when needed (at least for internal project consistency) is still a definite nice-to-have, no? |
So apparently what's needed is the NG2 version of: https://github.com/angular/angular.js/blob/master/src/ng/directive/a.js |
So the Bootstrap 4-alpha.3 release made this topic rather urgent (styling is broken without
Alternative, practical proposals (that is: ones we can turn into code and merge) are more than welcomed!!! |
That approach (#493) has worked out the best so far in the angular-ui-bootstrap library. |
Very important voice in our discussion: twbs/bootstrap#20737 It looks like using buttons for all those links would be a sensible way to go. We need to follow up on this issue. |
I find it interesting (and this in no way invalidates the issue filed) that the account used to file that issue was literally created today. |
@pkozlowski-opensource Is there some list of todos for this issue? What is the current status? |
@dmytroyarmak there is no particular TODO. The status is that we want to do full accessibility review with people using screen readers and then incorporate changes based on their feedback. But it will take time. If you / anyone else know people using screen readers on a daily basis we would love to hear about any issues encountered in practice. |
After over a year we are well set on the "pattern" from #493. Now new information surfaced as of lately and I don't see us revising the approach without new info. Based on this I'm going to close this issue for now but will keep an eye on any new developments in this area. |
A very common markup in Angular version of bootstrap directives goes like this:
<a (click)="prev()">Previous</a>
Pure bootstrap version would have an "empty" href (
<a (click)="prev()" href="#">Previous</a>
) to provide appropriate styling (cursor) but this is not needed in ng-version and can interfere with routing.The question: how do we deal with this situation? Few ideas:
$event
and callpreventDefault()
on it; this is what we do in the accordion, for example: https://github.com/ng-bootstrap/core/blob/1d912de06578aca1eaea9ad69942978090da43ff/src/accordion/accordion.ts#L42href
altogether and add cursor styling through CSS (this would be quite easy with ng2 since we've got styles encapsulation)Now, I must admit that I don't know what is the impact of removing
href
on accessibility and keyboard navigation, so the encapsulated CSS path might be a non-option in the end...Thoughts?
The text was updated successfully, but these errors were encountered: