-
Notifications
You must be signed in to change notification settings - Fork 841
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
[EuiResizableContainer] Mouse drags outside of the container no longer lose dragging state #7456
Changes from all commits
3f1346b
a291648
10bf4ee
1e20797
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
- Enhanced `EuiResizableContainer` to preserve the drag/resize event when the user's mouse leaves the parent container and re-enters |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,11 +34,10 @@ interface Params { | |
onPanelWidthChange?: ({}: { [key: string]: number }) => any; | ||
} | ||
|
||
function isMouseEvent( | ||
event: ReactMouseEvent | ReactTouchEvent | ||
): event is ReactMouseEvent { | ||
return typeof event === 'object' && 'pageX' in event && 'pageY' in event; | ||
} | ||
export const isTouchEvent = ( | ||
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. This wasn't previously exported. Did you mean to add this as an export? 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. I figured I might as well, although I'm happy to revert if needed! I originally grabbed this util for That being said, I could definitely see myself using this util again in other places in EUI in the future, if needed 🤔 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. I'm fine either way, I just wanted to double check. |
||
event: MouseEvent | ReactMouseEvent | TouchEvent | ReactTouchEvent | ||
): event is TouchEvent | ReactTouchEvent => | ||
typeof event === 'object' && 'targetTouches' in event; | ||
|
||
export const pxToPercent = (proportion: number, whole: number) => { | ||
if (whole < 1 || proportion < 0) return 0; | ||
|
@@ -81,16 +80,13 @@ export const getPanelMinSize = ( | |
}; | ||
|
||
export const getPosition = ( | ||
event: ReactMouseEvent | ReactTouchEvent, | ||
event: ReactMouseEvent | MouseEvent | ReactTouchEvent | TouchEvent, | ||
isHorizontal: boolean | ||
) => { | ||
const clientX = isMouseEvent(event) | ||
? event.clientX | ||
: event.touches[0].clientX; | ||
const clientY = isMouseEvent(event) | ||
? event.clientY | ||
: event.touches[0].clientY; | ||
return isHorizontal ? clientX : clientY; | ||
): number => { | ||
const direction = isHorizontal ? 'clientX' : 'clientY'; | ||
return isTouchEvent(event) | ||
? event.targetTouches[0][direction] | ||
: event[direction]; | ||
}; | ||
|
||
const getSiblingPanel = ( | ||
|
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.
FWIW, our docs still have a copy of this method in use. Is
getPosition
exported from our package in a way that we can update our docs to use this approach as well?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.
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, thanks for catching this! It looks like we don't export any resizable utils, but I'm now wondering if we should. What do you think? Should we add a new public export for this, probably under
src/services
? Maybesrc/services/drag
, orsrc/services/touch_or_mouse
? 🤷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.
I'm not sure if its worth it or not. I had a suspicion people were copy/pasting this example verbatim and it might clean that up -- but I don't see any examples in Kibana where it looks like someone would have done so. I don't think we need to solve this now.
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.
Fair! Will leave this uncollapsed for now in case we decide to come back to this later on.