FocusCaptureMixin

This mixin wraps a component’s template such that, once the component gains the keyboard focus, Tab and Shift+Tab operations will cycle the focus within the component.

This mixin expects the component to provide:

  • A template-stamping mechanism compatible with ShadowTemplateMixin.

The mixin provides these features to the component:

  • Template elements and event handlers that will cause the keyboard focus to wrap.

This mixin contributes to a component's template. See that discussion for details on how to use such a mixin.

API

inject(template) method

Wrap a base template with elements necessary to capture focus.

Call this method in a components symbols.template property.

Note: The wrap method hangs off of FocusCaptureMixin like a static method; the mixin does not add it to an element's prototype chain. Accordingly, you must invoke this method as FocusCaptureMixin.wrap(template), not this.wrap(template).

Parameters:
  • template: stringfor the element(s) controlled by the arrow buttons

Returns: string a template that includes left/right arrow buttons