Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close on click outside vue-at #114

Open
rutujak92 opened this issue Dec 13, 2019 · 2 comments
Open

close on click outside vue-at #114

rutujak92 opened this issue Dec 13, 2019 · 2 comments

Comments

@rutujak92
Copy link

rutujak92 commented Dec 13, 2019

I want to close @at dropdown on outside click is there an option to do this?

@rutujak92 rutujak92 changed the title disable vue-at close on click outside vue-at Dec 13, 2019
@fritx
Copy link
Owner

fritx commented Dec 15, 2019

@rutujak92 yes, If you just want the dropdown to hide when clicking outside of the editor, there is a solution (see #20 (comment)), you can try it.

In stead if you need the feature you want it to hide when clicking outside anywhere, you can probably change the target to window or document to bind some once listener to make it work.

@fritx
Copy link
Owner

fritx commented Dec 15, 2019

<at ref="at">
  <div class="editor"
    @focus="handleFocus"
    @blur="handleBlur"></div>
</at>

<script>
export default {
  data () {
    return {
      blurTimer: null,
      hideOnBlur: true
    }
  },
  methods: {
    handleFocus () {
      if (this.hideOnBlur) {
        clearTimeout(this.blurTimer)
      }
    },
    handleBlur () {
      if (this.hideOnBlur) {
        this.blurTimer = setTimeout(()=>{
          this.$refs.at.closePanel()
        }, 1500)
      }
    }
  }
}
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants