Skip to content
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

perf(editor): Use virtual scrolling in RunDataJson.vue #10838

Merged
merged 7 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/editor-ui/src/components/RunDataJson.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,20 @@ export default defineComponent({
const selectedJsonPath = ref(nonExistingJsonPath);
const draggingPath = ref<null | string>(null);
const displayMode = ref('json');
const jsonDataContainerHeight = ref<number>();

return {
externalHooks,
selectedJsonPath,
draggingPath,
displayMode,
jsonDataContainerHeight,
};
},
mounted() {
const jsonDataContainer = this.$refs.jsonDataContainer as HTMLDivElement;
this.jsonDataContainerHeight = jsonDataContainer.offsetHeight;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you considered using https://vueuse.org/core/useElementSize/#usage ?

this implementation won't work properly if for some reason the user resizes the screen

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh interesting! Will update it to use it. Thanks for the suggestion. Did not know about it. As you can see, I'm a newbie in the FE.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @r00gm, either that or with manual listener but we need to make sure it's updated when the element is resized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will apply this PR is merged, as could not get the reference to the div in the template from the setup method. Probably because we are mixing setup method and options API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able, you just need to return it from the setup method but still nice that you did the migration.

},
computed: {
...mapStores(useNDVStore, useWorkflowsStore),
jsonData(): IDataObject[] {
Expand Down Expand Up @@ -147,7 +153,7 @@ export default defineComponent({
</script>

<template>
<div :class="[$style.jsonDisplay, { [$style.highlight]: highlight }]">
<div ref="jsonDataContainer" :class="[$style.jsonDisplay, { [$style.highlight]: highlight }]">
<Suspense>
<LazyRunDataJsonActions
v-if="!editMode.enabled"
Expand Down Expand Up @@ -178,6 +184,8 @@ export default defineComponent({
root-path=""
selectable-type="single"
class="json-data"
:virtual="true"
:height="jsonDataContainerHeight"
@update:selected-value="selectedJsonPath = $event"
>
<template #renderNodeKey="{ node }">
Expand Down Expand Up @@ -229,11 +237,10 @@ export default defineComponent({
left: 0;
padding-left: var(--spacing-s);
right: 0;
overflow-y: auto;
overflow-y: hidden;
line-height: 1.5;
word-break: normal;
height: 100%;
padding-bottom: var(--spacing-3xl);
RicardoE105 marked this conversation as resolved.
Show resolved Hide resolved

&:hover {
/* Shows .actionsGroup element from <run-data-json-actions /> child component */
Expand Down
Loading