@@ -20,7 +20,7 @@ import WebCButton from "@ui5/webcomponents/dist/Button";
20
20
import WebCPopover from "@ui5/webcomponents/dist/Popover" ;
21
21
import WebCFUserMenu , { UserMenuItemClickEventDetail } from "@ui5/webcomponents-fiori/dist/UserMenu" ;
22
22
import WebCFUserSettingsDialog from "@ui5/webcomponents-fiori/dist/UserSettingsDialog" ;
23
- import { ShellBar$NotificationsClickEvent } from "sap/ui/webc/fiori/ShellBar" ;
23
+ import { ShellBar$NotificationsClickEvent , ShellBar$ProfileClickEvent } from "sap/ui/webc/fiori/ShellBar" ;
24
24
25
25
// Icons
26
26
import "@ui5/webcomponents-icons/dist/menu2" ;
@@ -175,12 +175,16 @@ export default class App extends BaseController {
175
175
176
176
/**
177
177
* Called when the user clicks on the profile button.
178
- * This is used to open the user settings dialog.
178
+ * This is used to open the user menu and setup the settings dialog.
179
179
*/
180
- async onProfileClick ( ) : Promise < void > {
180
+ async onProfileClick ( e : ShellBar$ProfileClickEvent ) : Promise < void > {
181
181
const userMenu = this . getView ( ) . byId ( "userProfileMenu" ) . getDomRef ( ) as WebCFUserMenu ;
182
+
183
+ // Use the targetRef from the event as the opener
184
+ userMenu . opener = e . getParameter ( "targetRef" ) ;
182
185
userMenu . open = true ;
183
186
187
+ // Load the settings dialog if not already loaded
184
188
let settingsDialog = this . getView ( ) . byId ( "settings" ) as unknown as WebCFUserSettingsDialog ;
185
189
if ( ! settingsDialog ) {
186
190
const dialogFragment = await Fragment . load ( {
@@ -193,6 +197,7 @@ export default class App extends BaseController {
193
197
settingsDialog = dialogFragment as unknown as WebCFUserSettingsDialog ;
194
198
}
195
199
200
+ // Add event listener for user menu item clicks if not already added
196
201
if ( ! this . userMenuListenerAdded ) {
197
202
userMenu . addEventListener ( "item-click" , ( event : Event ) => {
198
203
const customEvent = event as CustomEvent < UserMenuItemClickEventDetail > ;
0 commit comments