Skip to content

Commit

Permalink
fix(editor-3001): make sure view name stays synced to tab (#27809)
Browse files Browse the repository at this point in the history
  • Loading branch information
EDsCODE authored Jan 23, 2025
1 parent ea1e385 commit 607d7da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion frontend/src/scenes/data-warehouse/editor/QueryTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IconPlus, IconX } from '@posthog/icons'
import { LemonButton } from '@posthog/lemon-ui'
import clsx from 'clsx'
import { useState } from 'react'
import { useEffect, useState } from 'react'

import AutoTab from './AutoTab'
import { NEW_QUERY, QueryTab } from './multitabEditorLogic'
Expand Down Expand Up @@ -45,6 +45,10 @@ function QueryTabComponent({ model, active, onClear, onClick, onRename }: QueryT
const [tabName, setTabName] = useState(() => model.name || NEW_QUERY)
const [isEditing, setIsEditing] = useState(false)

useEffect(() => {
setTabName(model.view?.name || model.name || NEW_QUERY)
}, [model])

const handleRename = (): void => {
setIsEditing(false)
onRename(model, tabName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ export const multitabEditorLogic = kea<multitabEditorLogicType>([
return {
query: props.monaco?.editor.getModel(model.uri)?.getValue() || '',
path: model.uri.path.split('/').pop(),
name: model.name || NEW_QUERY,
name: model.view?.name || model.name || NEW_QUERY,
view: model.view,
}
})
Expand Down Expand Up @@ -426,6 +426,7 @@ export const multitabEditorLogic = kea<multitabEditorLogicType>([
const types = logic.values.response?.types ?? []

await dataWarehouseViewsLogic.asyncActions.createDataWarehouseSavedQuery({ name, query, types })
actions.updateState()
},
saveAsInsight: async () => {
LemonDialog.openForm({
Expand Down

0 comments on commit 607d7da

Please sign in to comment.