22
Views
1
Comments
Close DropdownTags onmouseleave
Application Type
Reactive

Hi all,

For a project it was requested to close the DropdownTags widget, when your mouse leaves the widget. However, because the top bar and the dropdown part are different elements, I am not sure if I can use the onmouseleave event.

Is there a solution to this problem?

2025-03-19 06-26-09
Mayur Budukale
Champion

Hi @Damaris Jongbloed 

 Let me break down the problem and suggest a possible solution:

  1. The DropdownTags widget consists of two separate elements:
    • The top bar (trigger)
    • The dropdown part (content)
  2. The goal is to close the dropdown when the mouse leaves the entire widget area.
  3. The challenge is that onmouseleave might not work as expected because the two parts are separate elements.

Here's a potential solution:

  1. Create a container element that wraps both the top bar and the dropdown part.
  2. Use JavaScript to add an event listener for the 'mouseleave' event on this container.
  3. When the mouseleave event is triggered, close the dropdown.

Here's a rough outline of how you might implement this in OutSystems and JavaScript:

"

// Assuming you have a container element with id 'dropdownContainer'

// and a function to close the dropdown called 'closeDropdown'


document.addEventListener('DOMContentLoaded', function() {

    var container = document.getElementById('dropdownContainer');

    

    container.addEventListener('mouseleave', function() {

        closeDropdown();

    });

});

function closeDropdown() {

    // Your code to close the dropdown

}


Hope this helps,


Mayur

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.