fomantic / Fomantic-UI

Fomantic-UI is the official community fork of Semantic-UI
https://fomantic-ui.com
MIT License
3.55k stars 328 forks source link

nag('dismiss') throws error #2996

Open bootstrapdisruptive opened 7 months ago

bootstrapdisruptive commented 7 months ago

Bug Report

The nag('dismiss') function throws error. ('stopImmediatePropagation')

Steps to reproduce

  1. Create an HTML

    User

    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
  2. Add a few Nags with Javascript

await addNag("Headline", "This iis the Nag Text <br> with linebreak","error");
await addNag("Headline", "This iis the Nag Text <br> with linebreak");
  async addNag(sHeadline, sContent, sClass='') {
    const oHtml = $(`
    <div class="ui nag ${sClass}" style="display: block;">
      <div class="title">${sHeadline}</div>
        <div>${sContent}</div>
      <i class="close icon"></i>
    </div>`);
    if ( $('.ui.nags').length ) {
      $('.ui.nags').append(oHtml);
    } else {
      $('<div>', {
        class: 'ui fixed nags',
      }).prependTo('body').append(oHtml);
    }

    oHtml.nag({storageMethod: 'localStorage'});
    oHtml.nag('show');
  }
  1. try to dismiss the error nags $('.ui.nag.error').nag('dismiss');

Expected result

The nag disappears without a JavaScript error

Actual result

semantic.min.js:11 Uncaught TypeError: Cannot read properties of undefined (reading 'stopImmediatePropagation') at HTMLDivElement.dismiss (semantic.min.js:11:205425) at Object.invoke (semantic.min.js:11:209606) at HTMLDivElement. (semantic.min.js:11:209735) at Function.each (jquery.min.js:2:3129) at ce.fn.init.each (jquery.min.js:2:1594) at C.fn.nag (semantic.min.js:11:204074) at :1:20

Version

2.9.3

lubber-de commented 7 months ago

Fixed by #2997