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

Add event object to item command function #9

Open
justinsillou opened this issue Apr 12, 2024 · 0 comments
Open

Add event object to item command function #9

justinsillou opened this issue Apr 12, 2024 · 0 comments

Comments

@justinsillou
Copy link

Hello,

I would like to suggest a small modification to the Leaflet Cascade Buttons plugin that allows passing the event object to the item command functions. This change can be useful when accessing event properties (such as the event target) within the command functions.

Currently, the command functions for items are called directly without passing any arguments:

childButton.addEventListener('click', () => item.command());

I propose changing this line to the following:

childButton.addEventListener('click', (e) => item.command(e));

With this change, you can define command functions that accept the event object as a parameter, like this:

{
  icon: 'fas fa-home',
  command: (e) => {
    console.log('Button clicked:', e.target);
  }
}

This allows for more flexibility when handling item click events.

Thank you for considering this suggestion. I believe this small change can be helpful for developers who want to access event properties within their command functions.

Best regards,

Justin

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

No branches or pull requests

1 participant