bem / bem/bem-components

button: setText() stops click event propagation

Open
#1,631 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
330
Forks
88
PR merge metrics
No merged PRs in 30d

Description

Here is an example to reproduce the issue:

``` js
modules.require(['button', 'jquery'], function(Button, $) {

$('.button').bem('button').on('click', function() {
this.setText('Button was clicked!');
});

$(document).on('click', function() {
console.log('Event was propagated to the document!');
});

});
```

Click on the `button` changes it's text, but no clicks are bubbled to document.

The issue is really annoying in case the button is set inside `popup_auclosable`, as the popup stops being closed on the first "outside" clicks after the `button` had been clicked:

``` js
{
block : 'popup',
mods : { autoclosable : true },
content : {
block : 'button',
text : 'My button'
}
}
```

/cc @dfilatov

Contributor guide

Open the contributing guide

Research direction

Start with the button component's setText() behavior and reproduce the example from the issue, checking whether the click still reaches the document handler. Verify the fix with the popup autoclosable scenario: after clicking the button, an outside click should still close the popup.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.