Top-level add-node button creates disconnected component. (#10416)

Closes #10389.
This commit is contained in:
Kaz Wesley 2024-07-02 05:59:06 -07:00 committed by GitHub
parent 764259f36d
commit 2168cfdf6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View File

@ -39,16 +39,16 @@ test('Different ways of opening Component Browser', async ({ page }) => {
// (+) button // (+) button
await locate.addNewNodeButton(page).click() await locate.addNewNodeButton(page).click()
await expectAndCancelBrowser(page, '') await expectAndCancelBrowser(page, '')
// (+) button with selection (ignored)
await locate.graphNodeByBinding(page, 'final').click()
await locate.addNewNodeButton(page).click()
await expectAndCancelBrowser(page, '')
// Enter key // Enter key
await locate.graphEditor(page).press('Enter') await locate.graphEditor(page).press('Enter')
await expectAndCancelBrowser(page, '') await expectAndCancelBrowser(page, '')
// With source node // With source node
// (+) button
await locate.graphNodeByBinding(page, 'final').click()
await locate.addNewNodeButton(page).click()
await expectAndCancelBrowser(page, '', 'final')
// Enter key // Enter key
await locate.graphNodeByBinding(page, 'final').click() await locate.graphNodeByBinding(page, 'final').click()
await locate.graphEditor(page).press('Enter') await locate.graphEditor(page).press('Enter')
@ -117,7 +117,7 @@ test('Graph Editor pans to Component Browser', async ({ page }) => {
}) })
test('Accepting suggestion', async ({ page }) => { test('Accepting suggestion', async ({ page }) => {
// Clicking enry // Clicking entry
await actions.goToGraph(page) await actions.goToGraph(page)
await locate.addNewNodeButton(page).click() await locate.addNewNodeButton(page).click()
let nodeCount = await locate.graphNode(page).count() let nodeCount = await locate.graphNode(page).count()

View File

@ -496,6 +496,11 @@ function addNodeAuto() {
createWithComponentBrowser(fromSelection() ?? { placement: { type: 'viewport' } }) createWithComponentBrowser(fromSelection() ?? { placement: { type: 'viewport' } })
} }
function addNodeDisconnected() {
nodeSelection.deselectAll()
createWithComponentBrowser({ placement: { type: 'viewport' } })
}
function fromSelection(): NewNodeOptions | undefined { function fromSelection(): NewNodeOptions | undefined {
if (graphStore.editedNodeInfo != null) return undefined if (graphStore.editedNodeInfo != null) return undefined
const firstSelectedNode = set.first(nodeSelection.selected) const firstSelectedNode = set.first(nodeSelection.selected)
@ -715,7 +720,7 @@ const groupColors = computed(() => {
@collapseNodes="collapseNodes" @collapseNodes="collapseNodes"
@removeNodes="deleteSelected" @removeNodes="deleteSelected"
/> />
<PlusButton title="Add Component" @click.stop="addNodeAuto()" /> <PlusButton title="Add Component" @click.stop="addNodeDisconnected()" />
<Transition> <Transition>
<Suspense ref="codeEditorArea"> <Suspense ref="codeEditorArea">
<CodeEditor v-if="showCodeEditor" @close="showCodeEditor = false" /> <CodeEditor v-if="showCodeEditor" @close="showCodeEditor = false" />