-
Notifications
You must be signed in to change notification settings - Fork 33
fix: Typing in notebooks is laggy #1977
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
Changes from 2 commits
d042c3c
2c57223
c318d92
af19103
6e303eb
f7e61d6
dfd35ca
1739edb
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 |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import type { | |
| import Log from '@deephaven/log'; | ||
| import { usePrevious } from '@deephaven/react-hooks'; | ||
| import { RootState } from '@deephaven/redux'; | ||
| import throttle from 'lodash.throttle'; | ||
| import { useDispatch, useSelector } from 'react-redux'; | ||
| import PanelManager, { ClosedPanels } from './PanelManager'; | ||
| import PanelErrorBoundary from './PanelErrorBoundary'; | ||
|
|
@@ -46,6 +47,8 @@ const DEFAULT_LAYOUT_CONFIG: DashboardLayoutConfig = []; | |
|
|
||
| const DEFAULT_CALLBACK = (): void => undefined; | ||
|
|
||
| const STATE_CHANGE_DEBOUNCE_MS = 1000; | ||
|
|
||
| // If a component isn't registered, just pass through the props so they are saved if a plugin is loaded later | ||
| const FALLBACK_CALLBACK = (props: unknown): unknown => props; | ||
|
|
||
|
|
@@ -228,6 +231,11 @@ export function DashboardLayout({ | |
| } | ||
| }, [dehydrateComponent, isItemDragging, lastConfig, layout, onLayoutChange]); | ||
|
|
||
| const throttledHandleLayoutStateChanged = useMemo( | ||
| () => throttle(handleLayoutStateChanged, STATE_CHANGE_DEBOUNCE_MS), | ||
|
Collaborator
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 will need the trailing option I think so the final call is always run. Not sure if that's a default or how the specifics work, but make sure the final call is always executed.
Member
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.
Collaborator
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. Looks like the default is
Collaborator
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. Yep so this will currently call immediately, then again at the end of the timeout if the throttled function has been called again. So |
||
| [handleLayoutStateChanged] | ||
| ); | ||
|
|
||
| const handleLayoutItemPickedUp = useCallback( | ||
| (component: Container) => { | ||
| const componentId = LayoutUtils.getIdFromContainer(component); | ||
|
|
@@ -269,7 +277,7 @@ export function DashboardLayout({ | |
| setLayoutChildren(layout.getReactChildren()); | ||
| }, [layout]); | ||
|
|
||
| useListener(layout, 'stateChanged', handleLayoutStateChanged); | ||
| useListener(layout, 'stateChanged', throttledHandleLayoutStateChanged); | ||
| useListener(layout, 'itemPickedUp', handleLayoutItemPickedUp); | ||
| useListener(layout, 'itemDropped', handleLayoutItemDropped); | ||
| useListener(layout, 'componentCreated', handleComponentCreated); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.