-
Notifications
You must be signed in to change notification settings - Fork 18
feat(ui-6240): accept collapsed status on resizer panel, during mounting and props change #901
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| // Libraries | ||
| import React, {forwardRef, CSSProperties, useState} from 'react' | ||
| import React, {forwardRef, CSSProperties, useState, useEffect} from 'react' | ||
| import classnames from 'classnames' | ||
|
|
||
| // Components | ||
|
|
@@ -19,8 +19,12 @@ import {getColorsFromGradient} from '../../Utils/colors' | |
| export interface DraggableResizerHandleProps extends StandardFunctionProps { | ||
| /** Enables a 0.0 direction (Left/Up) Collapse button */ | ||
| isCollapsibleToLower?: boolean | ||
| /** Collapsed state observed from parent */ | ||
| collapsedLower?: boolean | ||
|
Contributor
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. Is this only an initial state that can be overriden by the collapse buttons? as in, when this prop is provided, can the user then override the collapse state by pressing the collapse buttons?
Author
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. yes, exactly. See the video. And the parent can still pass a prop too. Such that the parent can ask for the panel to collapse. e.g. when we are in SQL editing, and want to collapse certain panels, and reopen as needed.
Contributor
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. would
Author
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. it's both the initial, and any change based from the parent. Use case:
I also just thought of another use case. Let me make changes, and will ping you back once that's done. |
||
| /** Enables a 1.0 direction (Right/Down) Collapse Button */ | ||
| isCollapsibleToUpper?: boolean | ||
| /** Collapsed state observed from parent */ | ||
| collapsedUpper?: boolean | ||
| /** Function that updates panel positions after collapsing */ | ||
| onCollapseButtonClick: (direction: number, dragIndex: number) => void | ||
| /** Gets passed a function by being a child of DraggableResizer */ | ||
|
|
@@ -52,7 +56,9 @@ export const DraggableResizerHandle = forwardRef< | |
| className, | ||
| orientation, | ||
| isCollapsibleToLower = false, | ||
| collapsedLower = false, | ||
| isCollapsibleToUpper = false, | ||
| collapsedUpper = false, | ||
| onCollapseButtonClick, | ||
| dragging = false, | ||
| dragIndex = 9999, | ||
|
|
@@ -63,8 +69,21 @@ export const DraggableResizerHandle = forwardRef< | |
| }, | ||
| ref | ||
| ) => { | ||
| const [collapsibleLower, setCollapsibleLower] = useState<boolean>(false) | ||
| const [collapsibleUpper, setCollapsibleUpper] = useState<boolean>(false) | ||
| const [collapsibleLower, setCollapsibleLower] = useState<boolean>( | ||
| collapsedLower | ||
| ) | ||
| const [collapsibleUpper, setCollapsibleUpper] = useState<boolean>( | ||
| collapsedUpper | ||
| ) | ||
|
|
||
| useEffect(() => { | ||
| if (isCollapsibleToLower && collapsedLower) { | ||
| onCollapseButtonClick(0, dragIndex) | ||
| } | ||
| if (isCollapsibleToUpper && collapsedUpper) { | ||
| onCollapseButtonClick(1, dragIndex) | ||
| } | ||
| }, [ref, collapsedLower, collapsedUpper]) | ||
|
|
||
| const handleMouseDown = (): void => { | ||
| onStartDrag(dragIndex) | ||
|
|
||
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 mismatch in the markdown text versus storybook fixture.
2 versus 3