Skip to content

Commit

Permalink
Merge branch 'develop' into feature/AFORM-3869-ricktext-support-for-#
Browse files Browse the repository at this point in the history
  • Loading branch information
epi-qang2 authored Jan 9, 2024
2 parents c305a1b + e23dac6 commit 8256c68
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion samples/ManagementSite/Alloy.ManagementSite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="EPiServer.CMS.UI.VisitorGroups" Version="12.23.0" />
<PackageReference Include="EPiServer.CMS.UI.AspNetIdentity" Version="12.23.0" />
<PackageReference Include="EPiServer.ImageLibrary.ImageSharp" Version="2.0.1" />
<PackageReference Include="Optimizely.Headless.Form.Service" Version="0.1.0--inte-197" />
<PackageReference Include="Optimizely.Headless.Form.Service" Version="0.1.0--inte-231" />
<PackageReference Include="Optimizely.Cms.Content.EPiServer" Version="0.3.1" />
<PackageReference Include="EPiServer.Forms" Version="5.8.0-ci-021203" />
<PackageReference Include="EPiServer.OpenIDConnect" Version="3.2.0"/>
Expand Down
5 changes: 4 additions & 1 deletion src/@episerver/forms-react/src/components/FormBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,13 @@ export const FormBody = (props: FormBodyProps) => {
dispatchFunctions.updateSubmissionKey(response.submissionKey);
localFormCache.set(submissionStorageKey, response.submissionKey);

if (isFormFinalized.current || isProgressiveSubmit.current) {
message.current = response.messages.map(m => m.message).join("<br>");
}

if (isFormFinalized.current) {
formCache.remove(FormConstants.FormCurrentStep + form.key);
localFormCache.remove(submissionStorageKey);
message.current = response.messages.map(m => m.message).join("<br>");
//redirect after submit
let redirectToPage = submitButton?.properties?.redirectToPage
if(!isNullOrEmpty(redirectToPage)){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FileUpload, FormContainer, FormStorage, isNullOrEmpty } from "@episerver/forms-sdk"
import { FileUpload, FormContainer, FormStorage } from "@episerver/forms-sdk"
import React, { useMemo } from "react";
import ElementWrapper from "./shared/ElementWrapper";
import { useElement } from "../../hooks/useElement";
Expand Down Expand Up @@ -42,7 +42,7 @@ export const FileUploadElementBlock = (props: FileUploadElementBlockProps) => {
/>

<div className="FormFileUpload__PostedFile">
(Previous posted file(s): {prevFilenames} )
{prevFilenames && <>(Previous posted file(s): {prevFilenames} )</>}
</div>

<ValidationMessage element={element} validationResults={validationResults} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FormCache, FormContainer, FormStorage, ParagraphText, Url } from "@episerver/forms-sdk"
import { FormContainer, FormStorage, ParagraphText } from "@episerver/forms-sdk"
import React, { useMemo } from "react";
import ElementWrapper from "./shared/ElementWrapper";
import { useElement } from "../../hooks/useElement";
import { ElementCaption, ValidationMessage } from "./shared";
import { ElementCaption } from "./shared";
import { useForms } from "../../context/store";

export interface ParagraphTextElementBlockProps {
Expand Down Expand Up @@ -35,7 +35,7 @@ export const ParagraphTextElementBlock = (props: ParagraphTextElementBlockProps)

let replacedText = element.properties.paragraphText ?? ""
const indicators = ['::', "#"]

indicators.forEach(indicator => {
const placeHolders = extractTextsWithFormat(replacedText, indicator)
if (doReplaceText) {
Expand Down
15 changes: 11 additions & 4 deletions src/@episerver/forms-react/src/hooks/useElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,20 @@ export const useElement = (element: FormElementBase) => {

//update form state
let inactives = formContext?.dependencyInactiveElements ?? [];
let needUpdate = false;
if(isVisible.current){
inactives = inactives.filter(ek => !equals(ek, element.key));
if(inactives.includes(element.key)){
inactives = inactives.filter(ek => !equals(ek, element.key));
needUpdate = true;
}
}
else {
!isInArray(element.key, inactives) && inactives.push(element.key);
if(!isInArray(element.key, inactives)){
inactives.push(element.key);
needUpdate = true;
}
}
dispatchFuncs.updateDependencies(inactives);
needUpdate && dispatchFuncs.updateDependencies(inactives);
},[formContext?.formSubmissions]);

//focus on element if validate fail before submitting
Expand All @@ -117,7 +124,7 @@ export const useElement = (element: FormElementBase) => {

//disable submit button when form submitting
useEffect(()=>{
if(equals(element.contentType, "SubmitButtonElementBlock")){
if(equals(element.contentType, "SubmitButtonElementBlock") && elementRef.current){
elementRef.current.disabled = formContext?.isSubmitting ?? false;
}
},[formContext?.isSubmitting])
Expand Down

0 comments on commit 8256c68

Please sign in to comment.