Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FocusIf.ts « FocusIf « src « vue « CoreHome « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 665f2774c35b29305c7335998bcfc5e19d5025ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);
    }
  },
};