Skip to content

Commit b705419

Browse files
committed
Fixes for the ResizeObserver and actions editor
1 parent 852f952 commit b705419

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

src/components/panels/HeaderPanel.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
import { Component, Vue, Prop } from 'vue-property-decorator'
108108
import Popper from 'vue-popperjs'
109109
110+
import { debounceTillAnimationFrame } from '@/utils'
110111
import type { IUserViewType } from '@/components/FormControl.vue'
111112
import ButtonItem from '@/components/buttons/ButtonItem.vue'
112113
import type { Button } from '@/components/buttons/buttons'
@@ -181,7 +182,9 @@ export default class HeaderPanel extends Vue {
181182
private mounted() {
182183
if (this.$refs['headerPanel']) {
183184
/* eslint-disable-next-line @typescript-eslint/unbound-method */
184-
this.panelResizeObserver = new ResizeObserver(this.onPanelResize)
185+
this.panelResizeObserver = new ResizeObserver(
186+
debounceTillAnimationFrame(() => this.onPanelResize()),
187+
)
185188
this.panelResizeObserver.observe(this.$refs['headerPanel'] as HTMLElement)
186189
}
187190
}

src/components/views/Table.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ import {
471471
parseFromClipboard,
472472
waitTimeout,
473473
ClipboardParseValue,
474+
debounceTillAnimationFrame,
474475
} from '@/utils'
475476
import { valueIsNull } from '@/values'
476477
import { UserView } from '@/components'
@@ -2658,7 +2659,9 @@ export default class UserViewTable extends mixins<
26582659
},
26592660
)
26602661
if (this.$refs['tableWrapper']) {
2661-
this.tableResizeObserver = new ResizeObserver(this.onTableResize)
2662+
this.tableResizeObserver = new ResizeObserver(
2663+
debounceTillAnimationFrame(this.onTableResize),
2664+
)
26622665
this.tableResizeObserver.observe(
26632666
this.$refs['tableWrapper'] as HTMLElement,
26642667
)

src/utils.ts

+13
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ export const nextRender = (): Promise<void> =>
4747
)
4848
})
4949

50+
export const debounceTillAnimationFrame = (f: () => void): (() => void) => {
51+
let scheduled = false
52+
return () => {
53+
if (!scheduled) {
54+
scheduled = true
55+
requestAnimationFrame(() => {
56+
scheduled = false
57+
f()
58+
})
59+
}
60+
}
61+
}
62+
5063
/* eslint-disable import/no-mutable-exports */
5164
export declare let process: {
5265
env: Record<string, string>

vue.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export default {
4545
configureWebpack: {
4646
plugins: [
4747
new MonacoWebpackPlugin({
48-
languages: ['sql', 'javascript', 'json', 'html'],
48+
// `typescript` is needed when `javascript` is enabled.
49+
// Otherwise we get runtime errors when trying to edit actions.
50+
languages: ['sql', 'javascript', 'typescript', 'json', 'html'],
4951
}),
5052
new webpack.IgnorePlugin({
5153
resourceRegExp: /^\.\/locale$/,

0 commit comments

Comments
 (0)