-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ui] Refactoring to support asset health overview #21081
Changes from 1 commit
e8ac396
4077253
dd385af
3c5100b
ec535fd
2d059a3
a805341
3019fcc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,24 @@ export const ContextMenuWrapper = ({ | |
wrapperInnerStyles?: React.CSSProperties; | ||
}) => { | ||
const [menuVisible, setMenuVisible] = React.useState(false); | ||
const [menuPosition, setMenuPosition] = React.useState<{top: number; left: number}>({ | ||
top: 0, | ||
left: 0, | ||
const [menuPosition, setMenuPosition] = React.useState<{ | ||
x: number; | ||
y: number; | ||
anchor: 'left' | 'right'; | ||
}>({ | ||
anchor: 'left', | ||
x: 0, | ||
y: 0, | ||
}); | ||
|
||
const showMenu = (e: React.MouseEvent) => { | ||
const anchor = window.innerWidth - e.pageX < 240 ? 'right' : 'left'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of hardcoding 240 here should we take it as a prop with maybe 240 as the default? We could also use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm that's a good point, we probably should calculate this at runtime rather than hardcoding to 240 -- we'll need to do the first render invisibly I think to avoid it appearing left anchored and then jumping to the right anchor but I think we can do that 👀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. edit hrm, it looks like we have to render hidden, size, render visible to do this with the correct breakpoint, going to come back to it in a follow-up! |
||
e.preventDefault(); | ||
setMenuPosition({top: e.pageY, left: e.pageX}); | ||
setMenuPosition({ | ||
x: anchor === 'left' ? e.pageX : window.innerWidth - e.pageX, | ||
y: e.pageY, | ||
anchor, | ||
}); | ||
|
||
if (!menuVisible) { | ||
setMenuVisible(true); | ||
|
@@ -78,8 +88,9 @@ export const ContextMenuWrapper = ({ | |
<div | ||
style={{ | ||
position: 'absolute', | ||
top: menuPosition.top, | ||
left: menuPosition.left, | ||
top: menuPosition.y, | ||
left: menuPosition.anchor === 'left' ? menuPosition.x : 'unset', | ||
right: menuPosition.anchor === 'right' ? menuPosition.x : 'unset', | ||
backgroundColor: Colors.popoverBackground(), | ||
boxShadow: '0 2px 4px rgba(0, 0, 0, 0.1)', | ||
zIndex: 10, | ||
|
@@ -102,4 +113,5 @@ export const triggerContextMenu = (e: React.MouseEvent) => { | |
const evt = new MouseEvent('contextmenu', e.nativeEvent); | ||
e.target.dispatchEvent(evt); | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fix for right-clicking on an asset on the far right edge of the screen - the menu needs to be anchored from the other side so it's onscreen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooo I figured blueprint would have logic to make sure it's always visible regardless of setting, that's a bummer that it doesn't