Skip to content

Commit

Permalink
Fix missing prop errors from buttonLabels
Browse files Browse the repository at this point in the history
  • Loading branch information
randomnetcat committed Jul 15, 2024
1 parent 6a1e3d5 commit 3a58bf9
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/components/creator/schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,11 @@ export function makeSchema(chrome: ChromeAPI): Schema {

for (const step of schema.fields) {
if (step.component === componentTypes.WIZARD) {
for (const page of step.fields) {
for (const rawPage of step.fields) {
const page: typeof rawPage & {
buttonLabels?: { [key: string]: string };
} = rawPage;

// Add an lr-wizard-spy component to all wizard steps. It must be here (rather
// than at the top level of the schema) so that it is inside the WizardContext.
page.fields.push({
Expand All @@ -471,6 +475,21 @@ export function makeSchema(chrome: ChromeAPI): Schema {
if (page.buttons === undefined) {
page.buttons = CustomButtons;
}

// Fix missing prop errors for button labels
if (page.buttonLabels !== undefined) {
page.buttonLabels = {
next: 'Next',
cancel: 'Cancel',
back: 'Back',
...page.buttonLabels,
};

// Don't show "Submit" as a label, since this form is never submitted.
if (page.buttonLabels.submit === undefined) {
page.buttonLabels.submit = page.buttonLabels.next;
}
}
}
}
}
Expand Down

0 comments on commit 3a58bf9

Please sign in to comment.