freshworks / crayons

🖍️ Crayons - A UI Kit comprising of web components for building Freshworks Apps!
https://crayons.freshworks.com
219 stars 61 forks source link

[Bug] - fwLinkClick event not getting triggered on FwToastMessage Component #844

Open sarveswaran-ramanathan opened 1 year ago

sarveswaran-ramanathan commented 1 year ago

Component FwToastMessage

Describe the bug When using ToastController, FwToast to toast FwToastMessage with action-link-text, the event fwLinkClick is not getting triggered on clicking the linkg

To Reproduce Steps to reproduce the current behavior:

  1. Have a FwToastMessage with action-link-text
  2. Using ToastController or FwToast trigger the FwToastMessage.
  3. Click on the link.
  4. fwLinkClick is not getting emitted.

Expected behavior fwLinkClick should be emitted for us to handle.

code https://codesandbox.io/s/frosty-wood-o78453?file=/src/App.js:0-1760

arvindanta commented 1 year ago

@sarveswaran-ramanathan

Can you either use

window.addEventListener("fwLinkClick", (e) => {
    console.log(e.target); // check the e.target and perform actions based on the target clicked.
    alert("link clicked");
  });

or

you can create a custom link urself instead of using the action-link-text prop

<fw-toast-message type="success" id="custom-toast" timeout="6000">
      <div>
        <span class="custom-text">Custom content</span>
        <h4>custom html contents can be added</h4>
        <a href="#" onclick="alert('clicked')">custom link</a>
      </div>
</fw-toast-message>