layout | apiModuleName | apiBuiltName |
---|---|---|
doc-api.html |
ally/fix/pointer-focus-parent |
ally.fix.pointerFocusParent |
This Browser Bug Workaround targets an issue in old Blink and WebKit causing focus (by MouseEvent
and TouchEvent
) to be given to the next parent element accepting focus, rather than the element the event was
dispatched to.
Considering the following markup, clicking on the <a>
element would focus the <div>
instead:
<div tabindex="-1">
<a href="http://example.org/">Hello World</a>
</div>
- NOTE: Only engaged for WebKit (detected via user agent sniffing).
TODO: figure out how to integrate demo
<script src="path/to/ally.min.js"></script>
<script>
// engage the workaround for the entire document
var handle = ally.fix.pointerFocusParent();
// disengage the workaround
handle.disengage();
// engage the workaround only for a sub-tree
var handle = ally.fix.pointerFocusParent({
// context can be: String (query selector), Node, Array of Nodes, NodeList, HTMLCollection
context: document.getElementById('element-to-fix');
});
</script>
Using the module instead of the production build:
require([
'ally/fix/pointer-focus-children'
], function(fixPointerFocusParent) {
// engage the workaround the entire document
var handle = fixPointerFocusParent();
// disengage the workaround
handle.disengage();
// engage the workaround only for a sub-tree
var handle = fixPointerFocusParent({
// context can be: String (query selector), Node, Array of Nodes, NodeList, HTMLCollection
context: document.getElementById('element-to-fix');
});
});
See Getting Started for how to use CommonJS, AMD or ES6 modules.
Back to the API Documentation.