diff --git a/site/src/components/Repl/Input/ComponentSelector.svelte b/site/src/components/Repl/Input/ComponentSelector.svelte
index 6f69aba9fa..54212014fa 100644
--- a/site/src/components/Repl/Input/ComponentSelector.svelte
+++ b/site/src/components/Repl/Input/ComponentSelector.svelte
@@ -4,7 +4,6 @@
import { enter } from '../../../utils/events.js';
const { components, selected } = getContext('REPL');
- const dispatch = createEventDispatcher();
let editing = null;
@@ -33,7 +32,18 @@
function remove(component) {
let result = confirm(`Are you sure you want to delete ${component.name}.${component.type}?`);
- if (result) dispatch('remove');
+
+ if (result) {
+ const index = $components.indexOf(component);
+
+ if (~index) {
+ components.set($components.slice(0, index).concat($components.slice(index + 1)));
+ } else {
+ console.error(`Could not find component! That's... odd`);
+ }
+
+ selected.set($components[index] || $components[$components.length - 1]);
+ }
}
function selectInput(event) {
@@ -183,11 +193,11 @@
{:else}
{#if component === editing}
- {component.name + (/\./.test(component.name) ? '' : `.${component.type}`)}
+ {editing.name + (/\./.test(editing.name) ? '' : `.${editing.type}`)}
-