Skip to content
This repository was archived by the owner on Nov 4, 2025. It is now read-only.

Commit 453aaf8

Browse files
committed
Fixing unarchive/archive error in bindValues
1 parent 766b98a commit 453aaf8

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/components/search-bar.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,7 @@ export class SearchBar extends Component {
467467
editing: this.state.tokenValues,
468468
tokenValues: [...this.state.tokenValues.slice(0, idx), ...this.state.tokenValues.slice(idx + 1)]
469469
});
470-
this.state.activeMachine.bindValues(toEdit.value).then(() => {
471-
// hack to push the current value back into the archive when editing starts in the multivalue case
472-
if (this.state.activeMachine.state.isMultivalue) this.state.activeMachine.archive(true);
473-
});
470+
this.state.activeMachine.bindValues(toEdit.value, false, true);
474471
} else if (this.state.active) {
475472
this.setState({
476473
flashActive: false

src/lib/token-state-machine.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ export class TokenStateMachine extends EventEmitter {
5555
*
5656
* @param {Object | undefined} values - A optional array of (boxed) values to apply to the machine's states (applied from the root state onward). If any value is an array, all but the final value are added to the `State` archive.
5757
* @param {boolean} finalTransition - Whether or not to apply the final transition.
58+
* @param {boolean} editing - Whether or not the token we're binding to is being edited.
5859
*/
59-
async bindValues (values, finalTransition = false) {
60+
async bindValues (values, finalTransition = false, editing = false) {
6061
try {
6162
// bind to states
6263
if (values !== undefined) {
@@ -65,6 +66,7 @@ export class TokenStateMachine extends EventEmitter {
6566
delete copy.actionValues; // we don't need actionValues in copy.
6667
while (Object.keys(copy).length > 0) {
6768
const v = copy[this.state.vkey];
69+
this.state.reset();
6870
if (v === undefined) {
6971
await this.state.doInitialize(this.boxedValue);
7072
break; // we're missing a value for the current state, so break out.
@@ -78,7 +80,9 @@ export class TokenStateMachine extends EventEmitter {
7880
this.state.value = x;
7981
this.state.archiveValue(this.boxedValue, true);
8082
}
81-
this.state.unarchiveValue(); // make the last value the "active" one
83+
if (!editing) {
84+
this.state.unarchiveValue(); // make the last value the "active" one
85+
}
8286
} else {
8387
await this.state.doInitialize(this.boxedValue, [this.state.unboxValue(v)]);
8488
this.state.value = v;

src/style/lex.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ div.lex-box div.token, ul.entered-values li.entered-value {
8383

8484
&.active {
8585
padding: $lex-token-padding ($lex-token-padding + 16px) $lex-token-padding ($lex-token-padding + 2px);
86+
.token-input {
87+
cursor: text;
88+
}
8689
}
8790

8891
&.editing {

0 commit comments

Comments
 (0)