Using the mouseleave event to efficiently close a Bootstrap-Vue Tooltip

I've developed a custom color picker component in Vue 2 using a combination of bootstrap-vue's button and tooltip components as shown below:

<template>
    <div>
        <b-button
            ref="button"
            @click="openColors"
            variant="outline-secondary"
            pill
            dusk="tag-colorpicker-button"
            :class="showColorPickerError ? 'button-border' : ''"
        >
            <i :style="{color: color}" class="icon-gt icon-gt-circle"></i>
            <i class="icon-gt icon-gt-angle-down"></i>
        </b-button>
        <div id="tooltip-boundary">
            <b-tooltip
                boundary="window"
                :show.sync="show"
                :target="() => $refs['button']"
                triggers="manual"
                custom-class="colorpicker-tooltip"
                placement="bottom"       
            >
                <compact v-model="color"></compact>
            </b-tooltip>
        </div>

    </div>
</template>

https://i.sstatic.net/bBoLC.png

The challenge I'm facing is figuring out how to close the tooltip by clicking outside the color picker area. I've attempted various mouse event iterations (e.g. @mouseleave) on the <b-tooltip> component, but they are not being triggered. The mouse events work on the <b-button> element, but not on the expanded tooltip. From reviewing the tooltip component documentation, the only potential solution appears to be using border, but so far it hasn't worked.

I also tried using the `native modifier approach like this

<b-tooltip
    :show.sync="show"
    :target="() => $refs['button']"
    triggers="manual"
    custom-class="colorpicker-tooltip"
    placement="bottom"
    @mouseleave.native="myMethod"
>

but unfortunately, that doesn't get triggered either.

How can I successfully trigger an event on the displayed tooltip area? I know what needs to be done within the event, but I'm struggling to activate the native mouse events.

Answer №1

Swap out trigger="manual" for trigger="click blur":

  • click - activates the tooltip when the target is clicked.
  • blur - deactivates the tooltip when it loses focus.

See demo

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with table display within <div> element in React

Recently diving into React, I find myself in a situation where I need to display data in a table once it's ready or show 'Loading' if not. Currently, my render() function looks like this: return ( <div> { this.state.loaded ...

Utilizing useEffect Hooks to Filter Local JSON Data in React Applications

For my engineering page, I have been developing a user display that allows data to be filtered by field and expertise. Fields can be filtered through a dropdown menu selection, while expertise can be filtered using an input field. My initial plan was to ...

The value of the jQuery data on click event handler becomes 'undefined' when used within an AJAX handler

When I click on the Positive or Negative buttons, a jQuery event handler function is triggered. Each button passes different data objects to the handler. However, within the AJAX POST handler, I am unable to access the data from the click event. $('# ...

Employing Jquery for restricting checkbox selection based on parent HTML elements

UPDATE I am looking to limit checkbox selection in specific sections on the same page. To prevent conflicting inputs from different sections, I believe using the label selector <label data-addon-name="xxx"> as a separator is the best appro ...

Getting information from MongoDB using Node.js and Angular

Currently, I am facing difficulty in retrieving data from MongoDB (I'm also using Mongoose) and sending it to Angular in order to populate the ng-repeat list with the retrieved data. I have managed to either display the data on a blank page directly f ...

Assigning index values to child rows in AngularJS: a step by step guide

One of my requirements involves assigning index values to child rows. The structure includes group rows with child rows underneath. Currently, I am using ng-repeat along with $index for the children as shown below: HTML code: <table ng-repeat="nod ...

The redirect function is failing to carry the "req" parameter

Express Routes Troubleshooting app.get('/auth/google/redirect', passport.authenticate('google'), (req, res) => { console.log('req.user:', req.user) //>>>>>Outputs {username: 'bob', id: '.. ...

Is a webpage's sluggishness in Internet Explorer due to its lengthy page structure causing issues while loading quickly on other browsers?

My application has a page that is particularly long, around 8Mb of source HTML mainly comprised of tables. I am aware that this indicates poor architecture, but unfortunately, I am unable to make immediate changes due to certain constraints. In most brows ...

I'm currently working on a course assignment and I've encountered an issue where nothing happens when I try to execute node

Having trouble with the readline for input execution. Any helpful hints or tips? I've been using it in the same file for all exercises, checked stackoverflow too but realized I'm on Windows. This is my code const { rejects } = require('asse ...

"Enhancing Your List: A Comprehensive Guide to Editing List Items with the Power of AJAX, jQuery, and

At the moment, I am able to edit a list item by clicking the 'Edit' link. However, I would prefer to simply click on the list item itself to initiate the editing process. This is the content of my _item.html.erb partial. In this case, each proj ...

The problem with 500 localStorage not being defined in Nuxt.js is causing

Issue with [nuxt] [request error]: [unhandled] [500] Error - localStorage is not defined ۱۴:۴۲:۵۶ at isAuthenticated (C:\Users\Lenovo\Desktop\CR ...

How to stop parent event propagation in jQuery

I am facing a frustrating issue with my code. Every time I toggle a checkbox, the parent element's click event also triggers. I have experimented with various solutions like: event.stopImmediatePropagation(); event.stopPropagation(); event.preventD ...

When using Javascript, an error is being thrown when attempting to select a nested element, stating that it is not a function

I am facing a challenge in selecting an element within another element, specifically a button within a form. Typically, I would use jQuery to achieve this as shown below: element = $('#webform-client-form-1812 input[name="op"]'); However, due t ...

React Native: The function `useContext.getItemsCount()` is returning a value of undefined, which is not an object

As a newcomer to React Native, I encountered an error when calling getItemsCount. *To view images, please click on the following links: https://i.sstatic.net/wbwjZ.png This snippet shows the code for CartIcon.js: import React, {useContext} from 'r ...

What seems to be causing the malfunction in my child component's functionality?

When passing data to child components using props, sometimes it may seem like the tag isn't working properly. For example, in this case, why isn't 'hello' being printed out? Here is the code snippet: <div id="app"> <child m ...

req.body is not defined or contains no data

I am facing an issue with my controllers and routers. bookController.js is functioning perfectly, but when I try to use userControllers for registration and login logic, req.body always appears empty. I tried logging the form data using console.log, but it ...

Animation showing on the progress bar is not correctly halted

I am encountering a problem with handling an animation of a progress bar in my code. The issue arises when I pause the animation, as it seems to slightly backtrack instead of pausing at the correct position upon clicking a button. Can someone help identify ...

Can JSON encoding in a URL pose a risk of XSS attacks?

To ensure my application has URL-friendly capabilities, I am storing its context as a JSON within the URL. This results in something like: http://mysite.dev/myapppage/target#?context={%22attr1%22%3A{%22target_id-0%22%3A{%22value%22%3A%223%22%2C%22label%2 ...

What is the process for importing Buffer into a Quasar app that is using Vite as the build tool

I'm having issues with integrating the eth-crypto module into my Quasar app that utilizes Vite. The errors I'm encountering are related to the absence of the Buffer object, which is expected since it's typically found in the front end. Is ...

Make sure to place the <i> tag within the <li> tag at the bottom to automatically resize the height

Currently, I am working on customizing my menu design with a mix of bootstrap and font awesome CSS styles. It would be easier to demonstrate the issue on a live page. My main objectives are two-fold: I want to position the chevron icon at the bottom with ...