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

[4.x]: Impossible to attach click event listener to autosuggestField suggestions #14633

Open
MatthiasBrodelet opened this issue Mar 20, 2024 · 0 comments

Comments

@MatthiasBrodelet
Copy link

What happened?

Description

I'm building a custom plugin with autosuggestField.
With JS I would like to register when a user clicks one of the suggestions and when the inputfield is being filled in with the new value. Since there is no built in way to listen to this type of event I have created a global click event on the document.
But to my surprise this gets triggered everywhere in the document including the input field but not the suggestions which are basically list items.

I would like to do this because I want to prefill other fields with additional information related to the chosen suggestion of the autosuggestField.

Steps to reproduce

  1. Use autosuggestField in a custom plugin
  2. Try to trigger a JS event to know what suggestion has been chosen

Expected behavior

I would like to at least know when a user clicks one of the suggestions.

Actual behavior

Nothing happens.
The event is not being triggered.
I assume it is being blocked by internal functions.

Craft CMS version

4.8.3

PHP version

8.1

Operating system and version

MacOS sonoma

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

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

1 participant