What is a “supported UI event”? Is it possible to switch off this limitation as it doesn’t make any sense for users (if they don’t like plugin they can always drop it or complain on it) and just make development more tricky?
Case 1. I have a form with submit event handler where I need to save some data into the document but I’m facing the error as form submit seems to be not supported UI event.
<form (ngSubmit)="onSubmit()" #createForm="ngForm">
<button uxp-variant="cta" type="submit"
[disabled]="!createForm.form.valid || isCreating">Create</button>
</form>
Case 2. I made workaround and bind write function to the click but it doesn’t work again as I need to await for another operation:
<button uxp-variant="cta" type="submit"
[disabled]="!createForm.form.valid || isCreating" (click)="onSubmit()">Create</button>
public async onSubmit(): Promise<void> {
try {
// this works
await this.service.setRecent({ id: 0, name: "noname" });
console.log("Faked saved to the document");
} catch (ex) {
console.log("Failed to save fake", ex);
}
try {
this.isCreating = true;
this.bundle.project = await this.api.createProject(newProject);
try {
// And this doesn't work
await this.service.setRecent(this.bundle.project);
console.log("Real saved to the document"); // never called
} catch (ex) {
console.log("Failed to save real", ex);
}
} catch (ex) {}
}