From f9eeefb4dca55aec17f2e5088ac483cdcd257b95 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 27 Oct 2020 12:32:48 +0000 Subject: [PATCH] Making sure the caret position is respected in the generic binding popover. --- packages/builder/package.json | 2 +- .../userInterface/GenericBindingPopover.svelte | 13 ++++++++++++- packages/builder/yarn.lock | 16 ++++++++-------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/packages/builder/package.json b/packages/builder/package.json index 12067716e9..cc37af2b63 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -63,7 +63,7 @@ } }, "dependencies": { - "@budibase/bbui": "^1.44.1", + "@budibase/bbui": "^1.47.0", "@budibase/client": "^0.2.6", "@budibase/colorpicker": "^1.0.1", "@fortawesome/fontawesome-free": "^5.14.0", diff --git a/packages/builder/src/components/userInterface/GenericBindingPopover.svelte b/packages/builder/src/components/userInterface/GenericBindingPopover.svelte index 5ad1a2c79f..f084f08989 100644 --- a/packages/builder/src/components/userInterface/GenericBindingPopover.svelte +++ b/packages/builder/src/components/userInterface/GenericBindingPopover.svelte @@ -18,10 +18,20 @@ export let align export let popover = null + let getCaretPosition + $: categories = Object.entries(groupBy("category", bindings)) function onClickBinding(binding) { - value += `{{ ${binding.path} }}` + const position = getCaretPosition() + const toAdd = `{{ ${binding.path} }}` + if (position.start) { + value = value.substring(0, position.start) + + toAdd + + value.substring(position.end, value.length); + } else { + value += toAdd + } } @@ -54,6 +64,7 @@