Skip to content

Commit

Permalink
Make sure reconfigurations that change a field's init value update th…
Browse files Browse the repository at this point in the history
…e field

FIX: Fix a bug where reconfiguring a field with a new `init` value didn't update
the value of the field.

Closes codemirror/dev#1515
  • Loading branch information
marijnh committed Feb 3, 2025
1 parent aba3881 commit 6c7eb3d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ export class StateField<Value> {
return SlotStatus.Changed
},
reconfigure: (state, oldState) => {
let init = state.facet(initField), oldInit = oldState.facet(initField), reInit
if ((reInit = init.find(i => i.field == this)) && reInit != oldInit.find(i => i.field == this)) {
state.values[idx] = reInit.create(state)
return SlotStatus.Changed
}
if (oldState.config.address[this.id] != null) {
state.values[idx] = oldState.field(this)
return 0
Expand Down

0 comments on commit 6c7eb3d

Please sign in to comment.