mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
fix(relationships): reset selection when returning to panorama
This commit is contained in:
1 parent
a3510939d5
commit
de3494bc7f
2 files changed
+38
-8
No files matched your search
@@ -529,17 +529,13 @@ function handleThreeCanvasFallback() {
|
||||
}
|
||||
|
||||
function backToPanorama() {
|
||||
const key = selectedKey.value
|
||||
cancelNeighborhoodLoad()
|
||||
clearNeighborhoodResponse()
|
||||
if (!key) return
|
||||
if (!graphResponse.value?.graph.nodes.some((node) => node.key === key)) {
|
||||
selectedKey.value = null
|
||||
canvasSelectedKey.value = null
|
||||
isDetailPanelOpen.value = false
|
||||
}
|
||||
selectedKey.value = null
|
||||
canvasSelectedKey.value = null
|
||||
isDetailPanelOpen.value = false
|
||||
void nextTick(() => {
|
||||
if (selectedKey.value) canvasRef.value?.focusNode(selectedKey.value)
|
||||
canvasRef.value?.fitView()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Run: pnpm test -- src/pages/people/relationships/relationship-galaxy-page-source.test.ts
|
||||
*/
|
||||
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { describe, it } from 'node:test'
|
||||
|
||||
function readPageSource(): string {
|
||||
return readFileSync(new URL('./index.vue', import.meta.url), 'utf8')
|
||||
}
|
||||
|
||||
describe('people relationships page source', () => {
|
||||
it('clears canvas selection when returning to the panorama', () => {
|
||||
const source = readPageSource()
|
||||
const backToPanorama = source.slice(
|
||||
source.indexOf('function backToPanorama()'),
|
||||
source.indexOf('function closeDetailPanel()')
|
||||
)
|
||||
|
||||
assert.ok(backToPanorama.includes('selectedKey.value = null'))
|
||||
assert.ok(backToPanorama.includes('canvasSelectedKey.value = null'))
|
||||
assert.ok(backToPanorama.includes('isDetailPanelOpen.value = false'))
|
||||
assert.ok(
|
||||
backToPanorama.includes('canvasRef.value?.fitView()'),
|
||||
'returning to panorama should fit the full graph instead of refocusing the selected node'
|
||||
)
|
||||
assert.equal(
|
||||
backToPanorama.includes('canvasRef.value?.focusNode(selectedKey.value)'),
|
||||
false,
|
||||
'returning to panorama must not keep the selected node focused'
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user