这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@alice
Copy link
Member

@alice alice commented Mar 8, 2017

@robdodson PTAL

@marcoscaceres
Copy link
Contributor

@alice, I might be wrong, but it seems you have not yet joined the WICG as a Google rep. Please visit the following link, and click "join this group". That should guide you and give you the right permissions. https://www.w3.org/community/wicg/

In the mean time, I'll mark this as non-substitantive.

@marcoscaceres
Copy link
Contributor

Marked as non-substantive for IPR from ash-nazg.

README.md Outdated

1. Add a new keyword value to the outline shorthand that represents whatever the default UA `::focus-ring` is. Then authors can do:

:focus {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest using :focus-ring

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not what you want, though. If you always want the focus ring to be shown (the use case in question), you want :focus.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry I thought this was more about our whole outline: ua discussion. Like if someone says :focus { outline: none } then there's no way for :focus-ring { } to ever get the default UA styles back

README.md Outdated
2. Add a new CSS property that controls "keyboard modality" vs non-"keyboard modality" behavior, e.g.

my-custom-texty-element {
should-show-focus-on-mouse-click-bikeshed: on-bikeshed;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like if we do this then why have :focus-ring at all? Not saying we shouldn't do this, just that it would probably supersede whatever :focus-ring has to offer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this complements :focus-ring by allowing you to choose when it gets matched (unlike :focus which always matches on focus regardless).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOOOOOOOH. got it. yes that would be nice. I think the way the use case was pitched didn't click in my head... also it's 1am

You may be able to rephrase it as:

In addition to `:focus-ring`, there are additional, speculative, missing primitives which may make working with focus easier.

1. An element should have a way to restore the UA default outline. Because each UA has a different default style, there's no easy way to restore the outline if a prior selector has overridden it (short of UA sniffing).

2. An element should have a way to express when it should display a focus ring. On keyboard focus, on mouse focus, or on both.

These could help explain the behavior of native text fields...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded.

demo/index.html Outdated
<p>
This page contains various html controls and demonstrates a proposal for only drawing a focus ring when the keyboard is being used.
Navigate through the interactive elements various ways (using mouse, switch to keyboard, try it on a touch device). You should see a green focus indicator (or comment out green focus ring style to see default focus ring) on elements below differently based on whether you interact with them via keyboard or mouse. If you are using the mouse and get lost, at any time you can tab/shift-tab to find your focus indicator.
Navigate through the interactive elements various ways (using mouse, switch to keyboard, try it on a touch device).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Navigate through the interactive elements in various ways"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we accidentally a word there.

@@ -1,67 +1,112 @@
/* https://github.com/WICG/focusring */
/* https://github.com/WICG/focus-ring */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops I merged my own PR that had this same change
#1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP 😄

document.addEventListener('DOMContentLoaded', function() {
var hadKeyboardEvent = false,
keyboardModalityWhitelist = [ 'input:not([type])',
var hadKeyboardEvent = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest using let and const throughout so we can be cool and hip. 🏂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't that mean it work work in some browsers and we'll have to go through all that pain again?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeaaaah i guess. ok can leave as var

hadKeyboardEvent = true;
// `activeElement` defaults to document.body if nothing focused,
// so check the active element is actually focused.
if (document.activeElement.matches(':focus')) {
Copy link
Collaborator

@robdodson robdodson Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be matcher.call(document.activeElement, ':focus')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derp

el.removeAttribute('data-focus-ring-added')
};
'[role=textbox]' ].join(',');
var matcher = (function() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you mind renaming this to matches? And adding a comment linking to the MDN post https://developer.mozilla.org/en-US/docs/Web/API/Element/matches

when I think of "matcher" my brain automatically assumes that this is already bound to a specific element. I have gone back and reread this chunk of code like 5 times and I still can't shake that feeling 😋

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had that briefly but matches by itself looks too much like it should be a list of matches (results) to me. matcher conveys that it's a function, IMO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok how about matchesFunction.


document.body.addEventListener('focus', function(e) {
/**
* On `focus`, add the `focus-ring` class to the target if necessary.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace if necessary with if the element matches a selector in the keyboardModalityWhitelist whitelist

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not accurate:

  • Will also add it if focus came from keyboard and the element doesn't match the whitelist
  • Will not add it if it was already there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add all of the above to the comment? 😸

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? They're implementation details.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I see the potential scenarios as critical pieces of information.

On `focus`, add the `focus-ring` class if one of the following scenarios is met:
- If focus came from the keyboard.
- If focus occurred before the keyboardThrottle expired.
- If the `target` is in the keyboardModalityWhitelist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok you convinced me.

var hadKeyboardEvent = false;
var keyboardThrottleTimeoutID = 0;

var keyboardModalityWhitelist = [ 'input:not([type])',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use a comment explaining why the whitelist exists. That it's for elements we want to always display a :focus-ring for

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@robdodson robdodson merged commit 7ff067a into WICG:master Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants