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

Trigger change is not working with action dispatch-event if there is no delay attribute #536

Open
abdelav opened this issue May 3, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@abdelav
Copy link

abdelav commented May 3, 2023

Using the a behavior change trigger to dispatch an event on <Text-field> element is not working if the behavior doesn't have the delay attribute.

Not working example:

<text-field name="phone" placeholder="Your phone number">
  <behavior trigger="change" action="dispatch-event" event-name="some-event" />
</text-field>

working example:

<text-field name="phone" placeholder="Your phone number">
  <behavior delay="0" trigger="change" action="dispatch-event" event-name="some-event" />
</text-field>
@abdelav abdelav added the bug Something isn't working label May 3, 2023
@adamstep
Copy link
Contributor

adamstep commented May 3, 2023

Let me test this in the demo app, will report back.

@adamstep
Copy link
Contributor

adamstep commented May 3, 2023

@abdelav did you notice this for other behavior actions, or only dispatch-event?

@abdelav
Copy link
Author

abdelav commented May 3, 2023

I just tested with dispatch-event so far, but let me test with other actions an I will report back.

@adamstep
Copy link
Contributor

adamstep commented May 3, 2023

I just tried it in the demo app and couldn't reproduce with dispatch-event: https://github.com/Instawork/hyperview/compare/adam/test-event1?expand=1

Simulator.Screen.Recording.-.iPhone.14.-.2023-05-03.at.16.41.14.mp4

@abdelav
Copy link
Author

abdelav commented May 3, 2023

ok, this is probably an internal issue then?

@adamstep
Copy link
Contributor

adamstep commented May 3, 2023

Perhaps, message me privately with the issue so we can check.

@Poundex
Copy link

Poundex commented Aug 12, 2024

Hello,

It looks like this might still be an issue. I have a <behavior /> with a trigger="change" and action="dispatch-event" which did not seem to be actually dispatching the event. After finding this issue and trying the delay="0" workaround it started working straight away (thanks, @abdelav !).

Here is some log output with the two scenarios:

With delay="0"

 INFO  [behavior] | action: set-value | ["<behavior trigger=\"change\" action=\"set-value\" target=\"zoomHotTub\" new-value=\" \" ran-once=\"true\" xmlns=\"h ttps://hyperview.org/hyperview\"/>"]
 INFO  [behavior] | action: dispatch-event | ["<behavior trigger=\"change\" action=\"dispatch-event\" event-name=\"refresh-zoom-form\" delay=\"0\" ran-once=\ "true\" xmlns=\"https://hyperview.org/hyperview\"/>"]
 INFO  [dispatch-event] action [refresh-zoom-form] emitted. []
 INFO  [behavior] | action: replace | ["<behavior trigger=\"on-event\" event-name=\"refresh-zoom-form\" action=\"replace\" href=\"/zoomcontrol\" verb=\"post\ " target=\"zoomform\" once=\"true\" ran-once=\"true\" xmlns=\"https://hyperview.org/hyperview\"/>"]
 INFO  [on-event] trigger [ ["refresh-zoom-form", "] caught by: ", "<behavior trigger=\"on-event\" event-name=\"refresh-zoom-form\" action=\"replace\" href=\ "/zoomcontrol\" verb=\"post\" target=\"zoomform\" once=\"true\" ran-once=\"true\" xmlns=\"https://hyperview.org/hyperview\"/>"]
 INFO  [dispatch-event] action [zoom-updated] emitted. []
 INFO  [behavior] | action: replace | ["<behavior trigger=\"on-event\" event-name=\"zoom-updated\" action=\"replace\" href=\"/zoombutton\" once=\"true\" ran- once=\"true\" xmlns=\"https://hyperview.org/hyperview\"/>"]
 INFO  [on-event] trigger [ ["zoom-updated", "] caught by: ", "<behavior trigger=\"on-event\" event-name=\"zoom-updated\" action=\"replace\" href=\"/zoombutt on\" once=\"true\" ran-once=\"true\" xmlns=\"https://hyperview.org/hyperview\"/>"]
 INFO  [behavior] | action: dispatch-event | ["<behavior trigger=\"load\" action=\"dispatch-event\" event-name=\"zoom-updated\" once=\"true\" ran-once=\"true \" xmlns=\"https://hyperview.org/hyperview\"/>"]

Without delay="0"

 INFO  [behavior] | action: set-value | ["<behavior trigger=\"change\" action=\"set-value\" target=\"zoomHotTub\" new-value=\" \" ran-once=\"true\" xmlns=\"h ttps://hyperview.org/hyperview\"/>"]
 INFO  [dispatch-event] action [refresh-zoom-form] emitted. []
 INFO  [behavior] | action: dispatch-event | ["<behavior trigger=\"change\" action=\"dispatch-event\" event-name=\"refresh-zoom-form\" ran-once=\"true\" xmln s=\"https://hyperview.org/hyperview\"/>"]

As you can see, the action: dispatch-event for the change event does appear in both logs, but the second is missing the expected [dispatch-event] action line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants