Skip to content

Commit

Permalink
refactor(ui5-shellbar): rename press handlers param (#300)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: press handlers used to have param "iconRef". As not always
an Icon is pressed (e.g. title is not an icon) - the parameter is renamed to targetRef.

Fixes: #297
  • Loading branch information
MapTo0 authored Apr 4, 2019
1 parent 2641ec6 commit 5d1c920
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
24 changes: 12 additions & 12 deletions packages/main/src/ShellBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ const metadata = {
* Fired, when the primaryTitle is pressed.
*
* @event
* @param {HTMLElement} iconRef dom ref of the clicked icon
* @param {HTMLElement} targetRef dom ref of the clicked element
* @public
*/
titlePress: {
detail: {
iconRef: { type: HTMLElement },
targetRef: { type: HTMLElement },
},
},

Expand All @@ -197,38 +197,38 @@ const metadata = {
*
*
* @event
* @param {HTMLElement} iconRef dom ref of the clicked icon
* @param {HTMLElement} targetRef dom ref of the clicked element
* @public
*/
notificationsPress: {
detail: {
iconRef: { type: HTMLElement },
targetRef: { type: HTMLElement },
},
},

/**
* Fired, when the profile icon is pressed.
*
* @event
* @param {HTMLElement} iconRef dom ref of the clicked icon
* @param {HTMLElement} targetRef dom ref of the clicked element
* @public
*/
profilePress: {
detail: {
iconRef: { type: HTMLElement },
targetRef: { type: HTMLElement },
},
},

/**
* Fired, when the product switch icon is pressed.
*
* @event
* @param {HTMLElement} iconRef dom ref of the clicked icon
* @param {HTMLElement} targetRef dom ref of the clicked element
* @public
*/
productSwitchPress: {
detail: {
iconRef: { type: HTMLElement },
targetRef: { type: HTMLElement },
},
},
},
Expand Down Expand Up @@ -306,7 +306,7 @@ class ShellBar extends WebComponent {
this._header = {
press: event => {
this.fireEvent("titlePress", {
iconRef: this.shadowRoot.querySelector(".sapWCShellBarMenuButton"),
targetRef: this.shadowRoot.querySelector(".sapWCShellBarMenuButton"),
});
},
};
Expand Down Expand Up @@ -610,19 +610,19 @@ class ShellBar extends WebComponent {

_handleNotificationsPress(event) {
this.fireEvent("notificationsPress", {
iconRef: this.shadowRoot.querySelector(".sapWCShellBarBellIcon"),
targetRef: this.shadowRoot.querySelector(".sapWCShellBarBellIcon"),
});
}

_handleProfilePress(event) {
this.fireEvent("profilePress", {
iconRef: this.shadowRoot.querySelector(".sapWCShellBarImageButton"),
targetRef: this.shadowRoot.querySelector(".sapWCShellBarImageButton"),
});
}

_handleProductSwitchPress(event) {
this.fireEvent("productSwitchPress", {
iconRef: this.shadowRoot.querySelector(".sapWCShellBarIconProductSwitch"),
targetRef: this.shadowRoot.querySelector(".sapWCShellBarIconProductSwitch"),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@

<script>
shellbar.addEventListener("profilePress", function(event) {
popover.openBy(event.detail.iconRef);
popover.openBy(event.detail.targetRef);
window["press-input"].value = "Profile";
});

shellbar.addEventListener("titlePress", function(event) {
window["app-list-popover"].openBy(event.detail.iconRef);
window["app-list-popover"].openBy(event.detail.targetRef);
window["press-input"].value = "Title";
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ <h3>ShellBar</h3>

<script>
shellbar.addEventListener("profilePress", function(event) {
window["action-popover"].openBy(event.detail.iconRef);
window["action-popover"].openBy(event.detail.targetRef);
});

shellbar.addEventListener("titlePress", function(event) {
window["app-list-popover"].openBy(event.detail.iconRef);
window["app-list-popover"].openBy(event.detail.targetRef);
});
</script>
</div>
Expand Down Expand Up @@ -156,11 +156,11 @@ <h3>ShellBar</h3>

<script>
shellbar.addEventListener("profilePress", function(event) {
popover.openBy(event.detail.iconRef);
popover.openBy(event.detail.targetRef);
});

shellbar.addEventListener("titlePress", function(event) {
window["app-list-popover"].openBy(event.detail.iconRef);
window["app-list-popover"].openBy(event.detail.targetRef);
});
</script>
</xmp>
Expand Down

0 comments on commit 5d1c920

Please sign in to comment.