Skip to content

Commit

Permalink
Remove double deleteBox + delete node when doing backspace as well as…
Browse files Browse the repository at this point in the history
… delete (more useable on MacOs)
  • Loading branch information
joswarmer committed Oct 11, 2024
1 parent 0f894ab commit a80e5fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/core-svelte/src/lib/components/FreonComponent.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script lang="ts">
import { FREON_LOGGER } from "$lib/components/ComponentLoggers.js";
/**
* This component shows a complete projection, by displaying the rootbox of
* the associated editor.
Expand All @@ -25,7 +27,7 @@
import { afterUpdate, onMount, tick } from "svelte";
import { contextMenu, contextMenuVisible, selectedBoxes, viewport, componentId } from "$lib/components/svelte-utils/index.js";
let LOGGER = new FreLogger("FreonComponent");//.mute();
let LOGGER = FREON_LOGGER
export let editor: FreEditor;
let element: HTMLDivElement; // The current main element of this component.
let rootBox: Box;
Expand Down Expand Up @@ -143,6 +145,7 @@
stopEvent(event);
break;
case DELETE:
case BACKSPACE:
editor.deleteBox(editor.selectedBox);
stopEvent(event);
break;
Expand Down Expand Up @@ -229,7 +232,7 @@
const refreshSelection = async (why?: string) => {
LOGGER.log("FreonComponent.refreshSelection: " + why + " editor selectedBox is " + editor?.selectedBox?.kind);
if (!isNullOrUndefined(editor.selectedBox) && !$selectedBoxes.includes(editor.selectedBox)) { // selection is no longer in sync with editor
if (!isNullOrUndefined(editor.selectedBox) ){ //&& !$selectedBoxes.includes(editor.selectedBox)) { // selection is no longer in sync with editor
await tick();
$selectedBoxes = getSelectableChildren(editor.selectedBox);
editor.selectedBox.setFocus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
// store the current value in the textbox, or delete the box, if appropriate
LOGGER.log(` save text using box.setText(${text})`)
if (box.deleteWhenEmpty && text.length === 0) {
editor.deleteBox(box);
// editor.deleteBox(box);
} else if (text !== box.getText()) {
LOGGER.log(` text is new value`)
box.setText(text);
Expand Down

0 comments on commit a80e5fa

Please sign in to comment.