KVv2 json cursor jumps on "enter"#27569
Merged
Merged
Conversation
|
CI Results: |
|
Build Results: |
…hings, hopefully fixed in next commits
Monkeychip
commented
Jul 3, 2024
Monkeychip
commented
Jul 3, 2024
Monkeychip
commented
Jul 3, 2024
hashishaw
approved these changes
Jul 9, 2024
Contributor
hashishaw
left a comment
There was a problem hiding this comment.
Beautiful job, and thanks for the detailed description!
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes Issue #27524. Took the scenic route to get to this solution. The heart of the problem is the KVv2 secret engine parses the
secretDataon every change to the json editor (detailed steps below). So when a user hits enter, the codemirror modifier is called and it compares a parsed json blob to a non parsed blob, determining they are different. That determination caused the cursor to jump to the beginning of the text editor—an annoying UX experience.I tried a variety of solutions and landed on the last option:
model.secretDatato be updated before save. Things like toggling between kv form fields, revealing obscured values, and diff views.model.secretDataon a new blur event I added to codemirror. This borks the same set of things as solution one. Changing the parsing event will always bork things because we need the kv form field data and json editor data to be in sync and they get out of sync if we save them at different events (kv form field saves on change). However, these approaches were worth a shot because it's how the other json editor instances all work and why none of them run into this issue.Details for reference
codemirrors .setValue—see here. Granted, we're on an older version, so here's the setValue we're actually using (I've tested the updated codemirror, it doesn't fix this).
Code walk through of why it wasn't working before:
onChange.codemirror-modifiermodify function here.namedArgs.contenthas been parsed, before thethis._editor.getValue()has been. Meaning that for a whitespace value like "enter" we're comparing:{foo: 'beep'}vs{ "foo": "beep" /n }So this only happens on the KVv2 Secrets engine and on whitespace events. The other JsonEditor instances (policies, cubbyhole, etc) all parse the json value
onSavelike workflows.TODO only if you're a HashiCorp employee
getting backported to N-2, use the new style
backport/ent/x.x.x+entlabelsinstead of the old style
backport/x.x.xlabels.the normal
backport/x.x.xlabel (there should be only 1).of a public function, even if that change is in a CE file, double check that
applying the patch for this PR to the ENT repo and running tests doesn't
break any tests. Sometimes ENT only tests rely on public functions in CE
files.
in the PR description, commit message, or branch name.
description. Also, make sure the changelog is in this PR, not in your ENT PR.