-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KVv2 json cursor jumps on "enter" #27569
Merged
Merged
Conversation
This file contains 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
Monkeychip
added
ui
regression
Used to indicate possible regressions between versions
backport/1.17.x
labels
Jun 21, 2024
github-actions
bot
added
the
hashicorp-contributed-pr
If the PR is HashiCorp (i.e. not-community) contributed
label
Jun 21, 2024
CI Results: |
Build Results: |
Monkeychip
added
backport/ent/1.15.x+ent
backport/ent/1.16.x+ent
Changes are backported to 1.16.x+ent
labels
Jun 27, 2024
…hings, hopefully fixed in next commits
ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js
Show resolved
Hide resolved
ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js
Outdated
Show resolved
Hide resolved
Monkeychip
commented
Jul 3, 2024
ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js
Show resolved
Hide resolved
Monkeychip
commented
Jul 3, 2024
Monkeychip
commented
Jul 3, 2024
hashishaw
approved these changes
Jul 9, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful job, and thanks for the detailed description!
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backport/ent/1.16.x+ent
Changes are backported to 1.16.x+ent
hashicorp-contributed-pr
If the PR is HashiCorp (i.e. not-community) contributed
regression
Used to indicate possible regressions between versions
ui
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
secretData
on 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.secretData
to be updated before save. Things like toggling between kv form fields, revealing obscured values, and diff views.model.secretData
on 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-modifier
modify function here.namedArgs.content
has 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
onSave
like workflows.TODO only if you're a HashiCorp employee
getting backported to N-2, use the new style
backport/ent/x.x.x+ent
labelsinstead of the old style
backport/x.x.x
labels.the normal
backport/x.x.x
label (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.