From b2b87464d71568d4cba44164988fff278831e050 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Thu, 22 Sep 2022 03:55:27 -0400 Subject: [PATCH] slate-suggenstions: adding `moveBackward` (#55576) (#55592) (cherry picked from commit e55003174a3bfd0947cc4aa189c68f966c3696b3) Co-authored-by: Sven Grossmann --- packages/grafana-ui/src/slate-plugins/suggestions.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/grafana-ui/src/slate-plugins/suggestions.tsx b/packages/grafana-ui/src/slate-plugins/suggestions.tsx index c893ad38b94..a6366e1a067 100644 --- a/packages/grafana-ui/src/slate-plugins/suggestions.tsx +++ b/packages/grafana-ui/src/slate-plugins/suggestions.tsx @@ -143,6 +143,8 @@ export function SuggestionsPlugin({ const preserveSuffix = suggestion.kind === 'function'; const move = suggestion.move || 0; + const moveForward = move > 0 ? move : 0; + const moveBackward = move < 0 ? -move : 0; const { typeaheadPrefix, typeaheadText, typeaheadContext } = state; @@ -180,7 +182,8 @@ export function SuggestionsPlugin({ .deleteBackward(backward) .deleteForward(forward) .insertText(suggestionText) - .moveForward(move) + .moveForward(moveForward) + .moveBackward(moveBackward) .focus(); return editor;