-
Notifications
You must be signed in to change notification settings - Fork 323
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
Small visualization fixes #9130
Conversation
let width = ref<Opt<number>>(props.width) | ||
let height = ref(150) | ||
// We want to debounce width changes, because they are saved to the metadata. | ||
const debouncedWidth = debouncedGetter(() => width.value, 300) | ||
watch(debouncedWidth, (value) => value != null && emit('update:width', value)) |
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 think it's not quite working properly. We have prop.width
, width
and debouncedWith
- the prop.width
will be updated only on debounce, but even then width
is not updated (ref is only initialized).
I think the getter below should return props.width
, and we could have a debounce version for events.
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 think it works fine. props.width
is the “persistent” width of the visualization, the one we save and load from the config. width
is a current width, it might not be equal to “props.width” because of debouncing, but they will sync eventually. When width
is updated (user resizes the visualization), we sync props.width
after timeout and everything is normal again.
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.
Ah, I could not find where do we set width, but it's in unchanged code.
@@ -49,7 +56,7 @@ function blur(event: Event) { | |||
const rootNode = ref<HTMLElement>() | |||
const contentNode = ref<HTMLElement>() | |||
|
|||
onMounted(() => (config.width = Math.max(config.nodeSize.x, MIN_WIDTH_PX))) | |||
onMounted(() => (config.width = Math.max(config.width ?? config.nodeSize.x, MIN_WIDTH_PX))) |
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 also a bit of strange mechanic: we update width in config (effectively updating it also in code's metadata if I read code properly) on mount, i.e. when showing visualization, possibly with the width the node happen to have ATM (it may depend even on the project loading stage). I think it's better when the metadata keeps the width set by user by resizing.
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.
The purpose of this code is a bit different:
If we have with from metadata (config.width
), then
- Set current width to at least
MIN_WIDTH_PX
Else - Set current width and metadata width to current node size, or MIN_WIDTH_PX, whichever is larger.
Without this change, we won’t load the width initially, we would always use config.nodeSize.x
.
Huge update, refactoring of a lot of code places. Shortcuts and focusing is now working almost ideally. Added new screencast to the description. Now visualizations are focusable, and you can trigger
Escape also works for closing visualizations. Code editor and other graph editor shortcuts also work. The one remaining issue is the behavior of Graph Editor which effectively ignores any shortcuts if any HTMLElement is focused at the moment. As visualizations can now be focused by mouse-clicking, it can give the user some confusion. See this code in graph editor: useEvent(window, 'keydown', (event) => {
;(!keyboardBusy() && (interactionBindingsHandler(event) || graphBindingsHandler(event))) ||
(!keyboardBusyExceptIn(codeEditorArea.value) && codeEditorHandler(event))
})
This possible change touches a lot of moving parts of the application, and I’m not comfortable enough doing so, especially because this code was recently touched to avoid issues with code editor. |
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 added some suggestions for improvements. But let's make them in a follow-up PR, as this one is waiting too long.
@@ -25,6 +25,7 @@ export const graphBindings = defineKeybinds('graph-editor', { | |||
openComponentBrowser: ['Enter'], | |||
newNode: ['N'], |
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.
We should remove this binding.
toggleFullscreen: ['Shift+Space'], | ||
exitFullscreen: ['Escape'], | ||
}) | ||
|
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.
Instead of duplicating bindings, I would make GraphEditor implement all handlers for visualizationBindings in similar way as toggleFullscreen is implemented (check for single selected node).
}) | ||
|
||
|
||
useEvent(window, 'keydown', (event) => keydownHandler(event)) |
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.
If GraphEditor handles nextType
event, then there's no need for every visualization listen at window level. Instead we could attach handler to it's div (but then let's make sure visualization is focused after going fullscreen).
Addressing review suggestions from #9130 - Removing `N` binding - Removing duplicated `Toggle fullscreen vis` binding A few important differences from the suggested implementation: 1. There is no easy way to implement `nextType` on GraphEditor – we simply don’t have the required API 2. The keydown handler in `GraphVisualization` must be defined on window level still, otherwise it won’t get keydown events unless visualization is focused, and thus `nextType` won’t work because of (1) No visual changes to the IDE.
Pull Request Description
Closes #9009
New video:
visualization.shortctus.mp4
Older videos:
visualization.fixes.mp4
preserving.vis.width.mp4
Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.