diff options
Diffstat (limited to 'plugins/CoreHome/vue/src/FocusIf/FocusIf.ts')
-rw-r--r-- | plugins/CoreHome/vue/src/FocusIf/FocusIf.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/CoreHome/vue/src/FocusIf/FocusIf.ts b/plugins/CoreHome/vue/src/FocusIf/FocusIf.ts new file mode 100644 index 0000000000..665f2774c3 --- /dev/null +++ b/plugins/CoreHome/vue/src/FocusIf/FocusIf.ts @@ -0,0 +1,27 @@ +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +import { DirectiveBinding } from 'vue'; + +interface FocusIfArgs { + focusIf: boolean; + afterFocus?: () => void; +} + +export default { + updated(el: HTMLElement, binding: DirectiveBinding<FocusIfArgs>): void { + if (binding.value.focusIf) { + setTimeout(() => { + el.focus(); + + if (binding.value.afterFocus) { + binding.value.afterFocus(); + } + }, 5); + } + }, +}; |