focusout

Vue directive to fire a function when focus exits from an element.

Usage

Open your console to see the results

<template>
  <div>
    <button>Focusing me from the div does something</button>
    <div v-focusout="onFocusout" class="focusout-example">
      <button>Focusing me does nothing</button>
      <button>Focusing me does nothing</button>
    </div>
    <button>Focusing me from the div does something</button>
  </div>
</template>

<script>
export default {
  methods: {
    onFocusout() {
      console.log("Concentrate, you're losing focus!!!");
    },
  },
};
</script>

<style>
.focusout-example {
  border: 1px solid;
}
</style>