Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for formio loader bug #61

Merged
merged 3 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/PdfSubmitButton/PdfSubmitButton.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { createForm, createBuilder } from "../../utils";

<Meta title="Components/Custom/PdfSubmitButton" />

# PdfSubmitButton
# PdfSubmitButton - BETA

This component is still in development and not a stable version.

TODO - description of this component.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
export default [
{
type: "content",
html: `<h2>Please follow <a href="#" target="_blank">this guide</a> to setup the form action before using this component.</h2>`,
html: `<h2>This component is still in development and not a stable version.</h2><h2>Please follow <a href="#" target="_blank">this guide</a> to setup the form action before using this component.</h2>`,
input: false,
weight: -10,
},
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/FormioLoader/FormioLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import defaultCreateFormController from "../../config/createForm.controller";

// plugin function to fix the namespace/project option doesn't pass to Formio.makeRequest/Formio.makeStaticRequest
const requestPluginHandler = (requestArgs, opts) => {
if (requestArgs.formio) {
if (requestArgs?.formio) {
const formioInstance = document.querySelector(
`[data-formio-form-url="${requestArgs.formio.formUrl}"]`
);
Expand All @@ -23,7 +23,7 @@ const requestPluginHandler = (requestArgs, opts) => {
// the request url generated by recaptcha component doesn't honor the form options
// https://github.com/formio/formio.js/blob/master/src/components/recaptcha/ReCaptcha.js#L114
// hence the workaround is to inject the project id to the url
if (requestArgs.url.includes(`${opts.formio.base}/recaptcha`)) {
if (requestArgs?.url?.includes(`${opts.formio.base}/recaptcha`)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does ? do to this code?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for object and then look for properties

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorthand for
if (requestArgs && requestArgs.url && requestArgs.url.includes(${opts.formio.base}/recaptcha))

requestArgs.url = requestArgs.url.replace(
`${opts.formio.base}/recaptcha`,
`${opts.formio.projectUrl}/recaptcha`
Expand Down