1. FOCUS Flashcards

1
Q

¿What is focus? (theoric explanation)

A

Focus refers to the control on the computer screen that receives input from the keyboard and from the clipboard when you paste.

Example: in order to type in a text field you first have to go over with your mouse and click on it. Well that act of clicking on the text field, that’s actually what focuses it. You may also know that if you then press the tab key it will then move focus to the next text field or available control.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

¿Why all the page functionality should be available using the keyboard?

A

Unless it’s something you couldn’t normally do with a keyboard like free hand drawing or something like that, all page functionality should be available using the keyboard because some users drive the computer entirely with the keyboard or some other type of discrete input device.

(For those users, focus is absolutely critical. It’s their primary means of reaching everything on the screen)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

¿What is focus? (Technical explanation)

A

Focus determines where keyboard events go in the page.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

¿How does focus is indicated?

A

The currently focused item is often indicated by a focus ring, where the actual styling of that ring depends on the browser and any additional styling that the page author may have applied.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Working with native elements

A

Working with native elements is great for focus behavior, because they’re automatically inserted into the tab order based on their position in the DOM.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Tip por TAB ORDER

A

To tab through my page every so often just to make sure I haven’t accidentally messed up the tab order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

¿Where can tabindex be used?

A

Tabindex attribute can be used when there are instances and you want to modify their tab order.

(Like if you’re building a component without a native analog (like a drop down), or if you need to have something off screen that should only be focusable when it appears, like perhaps a modal window)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

¿Where can tabindex be applied?

A

Tabindex can be applied to any HTML element, and it takes a range of numeric values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Tabindex of -1

A

A tabindex of -1 means that the element will not be in the tab order, but it can be programmatically focused via JavaScript, by calling the element’s focus method.

(This can be especially useful for off screen content which appears on screen in response to a user event.

When the new content is displayed, you may wish to call its focus method which will then direct future keyboard events to it.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Tabindex of 0

A

A tabindex of 0 will add the element to the natural tab order, plus, that element will also be focus full by calling its focus method.

(For example, here I’ve got a fancy button that I’ve created out of just a div. Now, without a tabindex attribute, if I press the Tab key, this element will not receive focus. By adding a tabindex of zero, now when I press the Tab key, this element gets focused, and future keyboard events get directed to it)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A tabindex of greater than zero

A

A tabindex of greater than zero, for instance something like tab index of 5 will jump the element to the front of the tab order regardless of where it is in the DOM.

(If there are multiple elements with a tabindex greater than zero, the order will start from the lowest value that is greater than zero and then work its way up.

In general, using a tabindex greater than zero is discouraged and considered a bit of an anti-pattern)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

About tab order

A

If you need to put something earlier in the tab order, the best bet is to move it up in the DOM.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

¿What may I add focus behavior to?

A

Normally, you only want to add focus behavior to interactive controls like buttons, tabs, drop downs, or anything that the user might provide input to, not our site content.

So when you’re adding a tab index attribute, stop and ask yourself, is this something the user is going to interact with?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

¿Which Elements Should Have Focus?

A

The following elements should have focus.

  1. Header links
  2. Search fields
  3. Form input fields
  4. Submit button
  5. Large Call to Action button,
  6. Footer links.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

About tabindex and the Site Content

A

I mentioned previously that you shouldn’t add tab index to site content as a general rule.

But there is one exception to this and that’s when you’re manipulating the page, in response to a user action.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

¿Whats is managing focus?

A

Managing Focus, and it’s an extremely important technique that keeps the user’s interactive context in sync with the visual representation of the site. We change the focus as the page changes, with the tabindex.

17
Q

¿What is a hidden link?

A

Is a hidden link that allows keyboard and switch device users the ability to jump straight to our page content. These links are often referred to as skip links.

18
Q

Steps to creat a skip link

A
  1. I’ll start by creating a named anchor.
  2. The href of this anchor refers to the ID of another element that I’ll have on the page.
  3. I’m also going to give this element a class of skip-link so I can refer to it in CSS later.
  4. I want the skip link to appear early in the DOM, so I’m going to put it before my navigation.
  5. To connect my skip-link to my main content, I’ll give my main element an ID of maincontent, which matches the href value up here. So these two are now connected.
19
Q

¿How does Roving Focus works?

A
  1. Roving focus works by setting tab index to -1 for all of the children and then zero on the currently active item.
  2. Our component then uses a keyboard event listener to determine which key the user has pressed. At which point we set tab index on the next item to zero,
  3. We set to have a next of the previously focused item to negative one.
  4. We call the focus method of this new soon to be focused item, this now moves our focus ring.
  5. And lastly I’m going to just move this checked attribute down to this element using SET attribute In this case I’m using the CSS in my element based on that checked attribute just style the state of the radio button.
  6. Now when I reach the bottom of this list and this last radio is focused and the user presses the down arrow, then we’re going to wrap back around.
  7. So we’ll set tab index to zero on this top item.
  8. We’ll move checked over there or call focus
  9. we’ll set tab index to negative one on the previously focused item.
20
Q

What to do when focus disappear?

A

Go down in my console and type the command document.activeelement or to use the chrome accessibility Dev tools extension (specifically inspector).

21
Q

¿Whats a keyboard trap?

A

A “keyboard trap” occurs when a person who uses a keyboard cannot move focus away from an interactive element or control using the keyboard alone.