Skip to content

Commit

Permalink
fix(ui5-avatar, ui5-icon): attach onclick handler based on interactiv…
Browse files Browse the repository at this point in the history
…e property (#3742)
  • Loading branch information
dobrinyonkov authored and fifoosid committed Sep 9, 2021
1 parent b6219c7 commit e61f46f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 8 additions & 6 deletions packages/main/src/Avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,14 @@ class Avatar extends UI5Element {
};
}

_onclick(event) {
if (this.interactive) {
// prevent the native event and fire custom event to ensure the noConfict "ui5-click" is fired
event.stopPropagation();
this.fireEvent("click");
}
onBeforeRendering() {
this._onclick = this.interactive ? this._onClickHandler.bind(this) : undefined;
}

_onClickHandler(event) {
// prevent the native event and fire custom event to ensure the noConfict "ui5-click" is fired
event.stopPropagation();
this.fireEvent("click");
}

_onkeydown(event) {
Expand Down
12 changes: 6 additions & 6 deletions packages/main/src/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,10 @@ class Icon extends UI5Element {
}
}

_onclick(event) {
if (this.interactive) {
// prevent the native event and fire custom event to ensure the noConfict "ui5-click" is fired
event.stopPropagation();
this.fireEvent("click");
}
_onClickHandler(event) {
// prevent the native event and fire custom event to ensure the noConfict "ui5-click" is fired
event.stopPropagation();
this.fireEvent("click");
}

get _dir() {
Expand Down Expand Up @@ -329,6 +327,8 @@ class Icon extends UI5Element {
this.ltr = iconData.ltr;
this.packageName = iconData.packageName;

this._onclick = this.interactive ? this._onClickHandler.bind(this) : undefined;

if (this.accessibleName) {
this.effectiveAccessibleName = this.accessibleName;
} else if (this.accData) {
Expand Down

0 comments on commit e61f46f

Please sign in to comment.