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

Dropdown onchange event is not fired #846

Closed
1 task done
nakovskijosif opened this issue Mar 4, 2019 · 13 comments
Closed
1 task done

Dropdown onchange event is not fired #846

nakovskijosif opened this issue Mar 4, 2019 · 13 comments

Comments

@nakovskijosif
Copy link

nakovskijosif commented Mar 4, 2019

Are you reporting a bug or a feature?

  • Bug

Expected Behavior

When value is change event should be fired

Actual Behavior

Event is not fired

Steps to Reproduce the Problem

Use the dropdown below
<axa-dropdown title="Please Select a value (Initial title)" native items='[ {"name": "Item 1", "value": "Item 1", "url": "#", "isSelected": false }, {"name": "Item 2", "value": "Item 2", "url": "#", "isSelected": true }, {"name": "Item 3", "value": "Item 3", "url": "#", "isSelected": false } ]' onAxaChange="alert('test')"> </axa-dropdown>

when value is changed the alert is not called.

@AndyOGo
Copy link

AndyOGo commented Mar 4, 2019

Thanks @nakovskijosif
Maybe related to #844 and #843 🤔

@jackblackCH
Copy link
Contributor

We are analyzing and fixing. @LucaMele mentioned that onChange should be triggered automatically on value change.

@LucaMele
Copy link
Contributor

LucaMele commented Mar 4, 2019

onAxaChange

@nakovskijosif
Copy link
Author

@AndyOGo @jackblackCH, thank you for your feedback.
Would you please have a look at the withReact implementation, at the moment it is not rendered and

setProps(): Custom Element not connected and props never update <axa-dropdown>​</axa-dropdown>​ setProps @ with-update.js:234 updateWebComponentProps @ with-react.js:194
message is displayed in console.

@AndyOGo
Copy link

AndyOGo commented Mar 4, 2019

@nakovskijosif
Thank you for your quick response.
We would very much appreciate a complete reproduction sample, e.g. at https://codesandbox.io/

Unfortunately the other issues at the moment are that:

Sorry personally I'm busy right now, but I'm sure the webhub team will help you.

@nakovskijosif
Copy link
Author

nakovskijosif commented Mar 7, 2019

Reproduction sample on the link below.
https://codesandbox.io/s/2pv73ojvvj
Please note that if you change the patterns-library version to 244 the sample works.

@jackblackCH
Copy link
Contributor

Reproduction sample on the link below.
https://codesandbox.io/s/2pv73ojvvj
Please note that if you change the patterns-library version to 244 the sample works.

It does not render the dropdown at all if I open the link

@nakovskijosif
Copy link
Author

That is correct, as of the latest major refactor the with react does not render, the reason being my comment above. If you change the version to 244 the component is rendered and the event is fired.

@jackblackCH
Copy link
Contributor

jackblackCH commented Mar 20, 2019

In version 244 I try this via the preview and also no alert()

  <axa-dropdown onAxaChange="alert('foo')" title="title" items='[{"name": "Item 1", "url": "#"}, {"name": "Item 2 loooooong", "url": "#"}, {"name": "Item 3", "url": "#"}]'>
  </axa-dropdown>

@jackblackCH
Copy link
Contributor

jackblackCH commented Mar 20, 2019

I tried your sandbox with version 244 and the alert does not work. https://codesandbox.io/s/2o19mm1mrn

@AndyOGo
Copy link

AndyOGo commented Mar 20, 2019

@nakovskijosif
@jackblackCH
@LucaMele
Holy moly, we didn't realize that this kind of thing isn't supported at all... attributes containing JavaScript code as string to be evaled.

I would say this isn't a bug, but rather wrong application.

@nakovskijosif
To listen for events, you have to:

  • either attach them if you use native JS, by addEventListener
  • or use React props, like onAxaChange={() => {}}

Nevertheless, the dropdowns onAxaChange event still seems to be broken 🤔

@nakovskijosif
Copy link
Author

Sorry for all the confusion, my sample do uses react props and that is how I'm using the with react version.
The sample in the description though is using inline javascript(was working with onchange before but not onAxaChange and that is how it is used on prod aem at the moment).

Maybe I should've separated this issue into two.
Thank you for the feedback.

@LucaMele
Copy link
Contributor

Closing as V2 is released. If issue is still relevant in v2, please re-open

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

4 participants