Skip to content

Commit

Permalink
Do not detach inputs every time the form is updated, but only when th…
Browse files Browse the repository at this point in the history
…e inputs list has changed
  • Loading branch information
brichet committed Mar 10, 2025
1 parent 857ba01 commit ef465fa
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/settings/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,7 @@ export class AiSettings extends React.Component<
.catch(console.error);
}

async componentWillUpdate(): Promise<void> {
if (!this._secretsManager) {
return;
}
const inputs = this._formRef.current?.getElementsByTagName('input') || [];
for (let i = 0; i < inputs.length; i++) {
if (inputs[i].type.toLowerCase() === 'password') {
(await this._secretsManager.list(SECRETS_NAMESPACE)).forEach(id =>
this._secretsManager?.detach(SECRETS_NAMESPACE, id)
);
}
}
}

componentDidUpdate(): void {
async componentDidUpdate(): Promise<void> {
if (!this._secretsManager) {
return;
}
Expand All @@ -125,6 +111,8 @@ export class AiSettings extends React.Component<
if (ArrayExt.shallowEqual(inputs, this._formInputs)) {
return;
}

await this._secretsManager?.detachAll(SECRETS_NAMESPACE);
this._formInputs = [...inputs];
this._unsavedFields = [];
for (let i = 0; i < inputs.length; i++) {
Expand Down

0 comments on commit ef465fa

Please sign in to comment.