Skip to content

Commit

Permalink
✨ [open-formulieren/open-forms#4720] Added form name to the title of …
Browse files Browse the repository at this point in the history
…the form step pages
  • Loading branch information
robinmolen authored and sergei-maertens committed Oct 24, 2024
1 parent eb0e1ac commit 88dc2df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/FormStep/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ const FormStep = ({form, submission, onLogicChecked, onStepSubmitted, onDestroyS
const currentStepIndex = form.steps.indexOf(formStep);
const submissionStep = submission.steps.find(s => s.formStep === formStep.url);

useTitle(formStep.formDefinition);
useTitle(formStep.formDefinition, form.name);

/**
* Fetches the form step data from the backend.
Expand Down
2 changes: 1 addition & 1 deletion src/components/Summary/SubmissionSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const SubmissionSummary = ({
description: 'Summary page title',
defaultMessage: 'Check and confirm',
});
useTitle(pageTitle);
useTitle(pageTitle, form.name);

const getErrors = () => {
let errors = [];
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/useTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import {useTitle as reactUseTitle} from 'react-use';

import {ConfigContext} from 'Context';

const useTitle = localTitle => {
const useTitle = (localTitle, regionalTitle = '') => {
let {baseTitle} = useContext(ConfigContext);
baseTitle = baseTitle ? baseTitle.trim() : '';
return reactUseTitle(baseTitle ? `${localTitle} | ${baseTitle}` : localTitle);

const titleParts = [localTitle, regionalTitle, baseTitle].filter(part => part !== '');
return reactUseTitle(titleParts.join(' | '));
};

export default useTitle;

0 comments on commit 88dc2df

Please sign in to comment.