question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addEventListener doesn't reflect cmpApi.uiVisible being toggled

See original GitHub issue

Version Which version does this occur on?

1.0.0-beta.18

Module Is it core, cmpapi, cli, stub, or testing?

cmpapi

Describe the bug A clear description of what the bug is.

After receiving the ‘tcloaded’ event I am toggling cmpApi.uiVisible with a custom command:

{ showUI: (callback) => { cmpApi.uiVisible = true; } }

Nothing is received from the addEventListener callback after this happens.

Steps to Reproduce Steps to reproduce the behavior:

Load the stub, then the cmpapi. Fire an addEventListener command and then set the tcString field of the cmpapi. You will see the ‘tcloaded’ is fired. Finally, toggle a cmpApi.uiVisible = true. Notice that no event is fired.

Expected behavior A clear description of what you expected to happen.

An event should be fired whenever cmpApi.uiVisible is toggled.

Actual behavior A clear description of what happened that was not expected.

No event was fired when cmpApi.uiVisible is fired.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
chrispatersoncommented, Mar 12, 2020

@michael-sharethis setting uiVisible should not trigger an event. Only when the tcModel (or tcString) is set on the CmpApi does the event trigger.

i’ve also noticed issues where the eventStatus field is set to “cmpuishown” even when i toggle cmpApi.uiVisible to false.

I’m aware of this issue and have a fix for it

0reactions
michael-sharethiscommented, Mar 17, 2020

@chrispaterson a few more things on this (i’ve upgraded to beta.19):

  1. after creating a cmpApi instance i’ll set its tcString and toggle uiVisible to true. the ‘tcloaded’ event will get called and not the ‘cmpuishown’ event. is this the desired behavior on your end?

  2. once i update cmpApi.tcString and set cmpApi.uiVisible = false, the ‘useractioncomplete’ event is fired. this is the right behavior. however, once i update cmpApi.tcString and set cmpApi.uiVisible = true, the ‘useractioncomplete’ event is fired again… shouldn’t the ‘cmpuishown’ event be fired there instead?

Read more comments on GitHub >

github_iconTop Results From Across the Web

addEventListener not working as it should - Stack Overflow
I have problem with adding event listener into JS...If i connect button with onclick attribute its working but if I delete it in...
Read more >
EventTarget.addEventListener() - Web APIs | MDN
The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered ...
Read more >
TypeScript doesn't allow event : CustomEvent in ... - GitHub
In my TypeScript project, I'm trying to write the following code: buttonEl.addEventListener( 'myCustomEvent', ( event : CustomEvent ) => { //do ...
Read more >
HTML DOM Document addEventListener() Method - W3Schools
Definition and Usage. The addEventListener() method attaches an event handler to a document. ; Syntax. document.addEventListener(event, function, Capture) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found