stencil icon indicating copy to clipboard operation
stencil copied to clipboard

bug: dependency built with stencil, used in react project, the event triggered twice!

Open fayeah opened this issue 3 years ago • 1 comments

Prerequisites

Stencil Version

2.13.0

Current Behavior

the details please check 'Steps to Reproduce' part.

Expected Behavior

click event should be triggered only once.

Steps to Reproduce

step1: create a component with stencil, let's call it TestClick; step2: add event for TestClick;

// ok event
 @Event({
    eventName: 'ok',
    composed: false,
    cancelable: false,
    bubbles: false,
  })
  onOk: EventEmitter<number>;

private _onOk = async (e) => {
    e.preventDefault();
    const okEv = this.onOk.emit('some value');
    if (!okEv.defaultPrevented) {
      console.log('not defaultPrevented');
      return;
    }
  };

step3: use this component (TestClick) in another react project; step4: add event click function, let's call it handleClick;

// use TestClick
 <TestClick onOk={(e) => handleClick(e)}></TestClick>

// handler
 const handleClick = (e) => {
 console.log('aaaaaa');
  };

then the log message 'aaaaaa' was logged twice, which means handleClick was called twice, not sure whether it is bubble issue or not, but this is a bit weird.

Code Reproduction URL

not now

Additional Information

please help to check, thanks.

fayeah avatar Aug 05 '22 09:08 fayeah

Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

Please reproduce this issue in an Stencil starter component library and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.

For a guide on how to create a good reproduction, see our Contributing Guide.

ionitron-bot[bot] avatar Aug 05 '22 12:08 ionitron-bot[bot]

I'm going to close this issue due to lack of reproduction case. If this is still an issue, please feel free to create a new issue with a minimal reproduction URL for the team to pull down and take a look at. Thanks!

rwaskiewicz avatar Aug 22 '22 12:08 rwaskiewicz