Repository navigation
Add a polyfill for the focus-visible selector - #5452
Conversation
| @@ -0,0 +1,2 @@ | |||
| !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";function e(e){var t=!0,n=!1,o=null,d={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function i(e){return!!(e&&e!==document&&"HTML"!==e.nodeName&&"BODY"!==e.nodeName&&"classList"in e&&"contains"in e.classList)}function s(e){e.classList.contains("focus-visible")||(e.classList.add("focus-visible"),e.setAttribute("data-focus-visible-added",""))}function u(e){t=!1}function a(){document.addEventListener("mousemove",c),document.addEventListener("mousedown",c),document.addEventListener("mouseup",c),document.addEventListener("pointermove",c),document.addEventListener("pointerdown",c),document.addEventListener("pointerup",c),document.addEventListener("touchmove",c),document.addEventListener("touchstart",c),document.addEventListener("touchend",c)}function c(e){e.target.nodeName&&"html"===e.target.nodeName.toLowerCase()||(t=!1,document.removeEventListener("mousemove",c),document.removeEventListener("mousedown",c),document.removeEventListener("mouseup",c),document.removeEventListener("pointermove",c),document.removeEventListener("pointerdown",c),document.removeEventListener("pointerup",c),document.removeEventListener("touchmove",c),document.removeEventListener("touchstart",c),document.removeEventListener("touchend",c))}document.addEventListener("keydown",function(n){n.metaKey||n.altKey||n.ctrlKey||(i(e.activeElement)&&s(e.activeElement),t=!0)},!0),document.addEventListener("mousedown",u,!0),document.addEventListener("pointerdown",u,!0),document.addEventListener("touchstart",u,!0),document.addEventListener("visibilitychange",function(e){"hidden"==document.visibilityState&&(n&&(t=!0),a())},!0),a(),e.addEventListener("focus",function(e){var n,o,u;i(e.target)&&(t||(n=e.target,o=n.type,"INPUT"==(u=n.tagName)&&d[o]&&!n.readOnly||"TEXTAREA"==u&&!n.readOnly||n.isContentEditable))&&s(e.target)},!0),e.addEventListener("blur",function(e){var t;i(e.target)&&(e.target.classList.contains("focus-visible")||e.target.hasAttribute("data-focus-visible-added"))&&(n=!0,window.clearTimeout(o),o=window.setTimeout(function(){n=!1,window.clearTimeout(o)},100),(t=e.target).hasAttribute("data-focus-visible-added")&&(t.classList.remove("focus-visible"),t.removeAttribute("data-focus-visible-added")))},!0),e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&e.host?e.host.setAttribute("data-js-focus-visible",""):e.nodeType===Node.DOCUMENT_NODE&&document.documentElement.classList.add("js-focus-visible")}if("undefined"!=typeof window&&"undefined"!=typeof document){var t;window.applyFocusVisiblePolyfill=e;try{t=new CustomEvent("focus-visible-polyfill-ready")}catch(e){(t=document.createEvent("CustomEvent")).initCustomEvent("focus-visible-polyfill-ready",!1,!1,{})}window.dispatchEvent(t)}"undefined"!=typeof document&&e(document)}); | |||
| //# sourceMappingURL=focus-visible.min.js.map | |||
There was a problem hiding this comment.
Should we also commit the .map file and the original .js file for debugging? (if not, should we remove the source mapping?)
|
While this is going to be a big boon to keyboard-only users, I think most mouse users will find these colors and indicators too jarring. What do you and/or @gtritchie think of guarding the behavior with a preference? |
| <component name="FacetManager"> | ||
| <facet type="gwt" name="GWT"> | ||
| <configuration> | ||
| <setting name="gwtSdkUrl" value="file://$MODULE_DIR$/lib/gwt/2.8.1" /> |
There was a problem hiding this comment.
This file is annoying (it's an IntelliJ metadata file), not sure we should even have it checked in. Given we currently do, it shouldn't be referencing gwt 2.8.1 (or 2.8.2, since we now use a custom version, aka gwt-rstudio-1.3.
I recently tweaked this file in my configuration to get rid of the FacetManager section altogether, see ba1591c#diff-0c742bc7155736d62bc3454aeb47871d
There was a problem hiding this comment.
I'm on the fence. Annoying that we use a custom version so it's kind of weird. If we're not going to keep it totally accurate maybe we should just remove it from the repo altogether?
Implement the https://github.com/WICG/focus-visible polyfill as per the https://www.w3.org/TR/UNDERSTANDING-WCAG20/navigation-mechanisms-focus-visible.html proposal to explicitly show keyboard focus separately from mouse focus.
The proposed colors are entirely placeholder but they work in our current light and dark styles. There are some anomalies where we have explicitly set focus in our themes that will need to be removed/changed (
input["checkbox"]:focus) but focus barely works in the program right now anyway.