Skip to content

Commit 5a894cd

Browse files
committed
Use LeftBottomActionButton render anchor
Signed-off-by: Lin Wang <[email protected]>
1 parent 4e6e71e commit 5a894cd

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

public/apps/account/account-nav-button.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { LogoutButton } from './log-out-button';
3636
import { resolveTenantName } from '../configuration/utils/tenant-utils';
3737
import { getShouldShowTenantPopup, setShouldShowTenantPopup } from '../../utils/storage-utils';
3838
import { getDashboardsInfo } from '../../utils/dashboards-info-utils';
39+
import { LeftBottomActionButton } from '../../../../../src/core/public';
3940
import './account-nav-button.scss';
4041

4142
export function AccountNavButton(props: {
@@ -173,15 +174,12 @@ export function AccountNavButton(props: {
173174

174175
// ToDo: Add aria-label and tooltip when isPlacedInLeftNav is true
175176
const innerElement = isPlacedInLeftNav ? (
176-
<EuiButtonEmpty
177-
size="xs"
178-
flush="both"
179-
className="accountNavButton"
180-
aria-expanded={isPopoverOpen}
181-
aria-haspopup="true"
182-
>
183-
<EuiAvatar name={username} size="s" />
184-
</EuiButtonEmpty>
177+
<LeftBottomActionButton
178+
title={username}
179+
icon={<EuiAvatar name={username} size="s" />}
180+
isNavDrawerLocked$={props.coreStart.chrome.getIsNavDrawerLocked$()}
181+
isChromeVisible$={props.coreStart.chrome.getIsVisible$()}
182+
/>
185183
) : (
186184
<EuiAvatar name={username} size="m" />
187185
);
@@ -191,7 +189,6 @@ export function AccountNavButton(props: {
191189
<EuiPopover
192190
data-test-subj="account-popover"
193191
id="actionsMenu"
194-
anchorPosition={isPlacedInLeftNav ? 'rightDown' : undefined}
195192
button={innerElement}
196193
isOpen={isPopoverOpen}
197194
closePopover={() => {
@@ -201,6 +198,8 @@ export function AccountNavButton(props: {
201198
onClick={() => {
202199
setPopoverOpen((prevState) => !prevState);
203200
}}
201+
// Add buffer 2 to avoid popover move to top center of anchor
202+
{...(isPlacedInLeftNav ? { anchorPosition: 'rightDown', buffer: 2 } : {})}
204203
>
205204
<EuiContextMenuPanel>{contextMenuPanel}</EuiContextMenuPanel>
206205
</EuiPopover>

0 commit comments

Comments
 (0)