dbeaver/pro#10177 pass defaults to main properties - #4538
Conversation
Up to standards ✅🟢 Issues
|
| // Don't call load in create mode. There we rely on the defaults set here, and useAutoLoad will load the part on mount. | ||
| if (this.formState.mode === FormMode.Edit) { | ||
| await this.optionsPart?.load(); | ||
| } |
There was a problem hiding this comment.
Something is off here
Previously we waited for part being loaded and set initialState. And only then we went to setting driverId and all attached config to it. And it was pretty straightforward and imperative for both form modes: create and edit
Right now it smells like race condition. What if in create mode we resolve setDriverId() before the optionsPart is actually loaded and set initialState?
There was a problem hiding this comment.
What was the original issue here? Maybe we can resolve it differently?
closes 10177
Root cause: formState was published before initialization completed. The mounted form triggered useAutoLoad(), racing with setDriverId() and overwriting driver defaults via setInitialState().
Fix: Initialize ConnectionFormState and ConnectionFormOptionsPart locally, load driver defaults, apply config, then assign the completed state to this.formState. getDefaults() now also preserves the current Options state.