Skip to content

Commit

Permalink
[open-formulieren/open-forms#3450] Fixed scrolling in mobile version,…
Browse files Browse the repository at this point in the history
…added aria-labelledby to nav
  • Loading branch information
vaszig committed Nov 22, 2023
1 parent a565209 commit b6895ec
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 5 deletions.
90 changes: 90 additions & 0 deletions src/components/App.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,93 @@ export const ActiveSubmission = {
await userEvent.click(beginButton);
},
};

export const SeveralStepsInMobileViewport = {
render,
args: {
title: 'Progress',
formTitle: 'Formulier',
steps: [
{
uuid: '9e6eb3c5-e5a4-4abf-b64a-73d3243f2bf5',
slug: 'step-1',
formDefinition: 'Step 1',
index: 0,
url: `${BASE_URL}forms/mock/steps/9e6eb3c5-e5a4-4abf-b64a-73d3243f2bf5`,
isApplicable: true,
completed: false,
},
{
uuid: '71fa50c1-53db-4179-9fe7-eb3378ef39ee',
slug: 'step-2',
formDefinition: 'Step 2',
index: 0,
url: `${BASE_URL}forms/mock/steps/71fa50c1-53db-4179-9fe7-eb3378ef39ee`,
isApplicable: true,
completed: false,
},
{
uuid: 'f4f82113-ac83-429b-a17b-c1b145831fa9',
slug: 'step-3',
formDefinition: 'Step 3',
index: 0,
url: `${BASE_URL}forms/mock/steps/f4f82113-ac83-429b-a17b-c1b145831fa9`,
isApplicable: true,
completed: false,
},
{
uuid: 'ae5af44e-004f-4d2f-be75-d46a22577244',
slug: 'step-4',
formDefinition: 'Step 4',
index: 0,
url: `${BASE_URL}forms/mock/steps/ae5af44e-004f-4d2f-be75-d46a22577244`,
isApplicable: true,
completed: false,
},
{
uuid: 'cae11cf8-2773-4d70-80f4-71e5828b6fe3',
slug: 'step-5',
formDefinition: 'Step 5',
index: 0,
url: `${BASE_URL}forms/mock/steps/cae11cf8-2773-4d70-80f4-71e5828b6fe3`,
isApplicable: true,
completed: false,
},
{
uuid: '3b14f4f5-2283-4a81-adf1-03848672c83b',
slug: 'step-6',
formDefinition: 'Step 6',
index: 0,
url: `${BASE_URL}forms/mock/steps/3b14f4f5-2283-4a81-adf1-03848672c83b`,
isApplicable: true,
completed: false,
},
{
uuid: '3f0a2763-74de-4957-b970-a5117f15b023',
slug: 'step-7',
formDefinition: 'Step 7',
index: 0,
url: `${BASE_URL}forms/mock/steps/3f0a2763-74de-4957-b970-a5117f15b023`,
isApplicable: true,
completed: false,
},
{
uuid: '03657dc1-6bb1-49cf-8113-4b663981b70f',
slug: 'step-8',
formDefinition: 'Step 8',
index: 0,
url: `${BASE_URL}forms/mock/steps/03657dc1-6bb1-49cf-8113-4b663981b70f`,
isApplicable: true,
completed: false,
},
],
ariaMobileIconLabel: 'Progress step indicator toggle icon (mobile)',
accessibleToggleStepsLabel: 'Current step in form Formulier: Stap 2',
},
parameters: {
chromatic: {disableSnapshot: true},
viewport: {
defaultViewport: 'mobile1',
},
},
};
8 changes: 6 additions & 2 deletions src/components/Caption.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import React from 'react';

import {getBEMClassName} from 'utils';

const Caption = ({children, component = 'caption'}) => {
const Caption = ({children, id, component = 'caption'}) => {
const Component = `${component}`;
return <Component className={getBEMClassName('caption')}>{children}</Component>;
return (
<Component id={id} className={getBEMClassName('caption')}>
{children}
</Component>
);
};

Caption.propTypes = {
Expand Down
10 changes: 7 additions & 3 deletions src/components/ProgressIndicator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const ProgressIndicator = ({
const [expanded, setExpanded] = useState(false);

const modifiers = [];
if (!expanded) {
if (expanded) {
modifiers.push('mobile-expanded');

Check warning on line 24 in src/components/ProgressIndicator/index.js

View check run for this annotation

Codecov / codecov/patch

src/components/ProgressIndicator/index.js#L24

Added line #L24 was not covered by tests
} else {
modifiers.push('mobile-collapsed');
}

Expand All @@ -36,15 +38,17 @@ const ProgressIndicator = ({

return (
<Card blockClassName="progress-indicator" modifiers={modifiers}>
<nav>
<nav aria-labelledby="proress-indicator-section">
<MobileButton
ariaMobileIconLabel={ariaMobileIconLabel}
accessibleToggleStepsLabel={accessibleToggleStepsLabel}
formTitle={formTitle}
expanded={expanded}
onExpandClick={() => setExpanded(!expanded)}
/>
<Caption component="h2">{title}</Caption>
<Caption id="proress-indicator-section" component="h2">
{title}
</Caption>
<List ordered>
{steps.map((step, index) => (
<ProgressIndicatorItem
Expand Down
4 changes: 4 additions & 0 deletions src/scss/components/_app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
display: flex;
}

@include bem.element('body') {
flex: 1;
}

@include bem.element('debug') {
margin-block-start: 2em;
}
Expand Down
9 changes: 9 additions & 0 deletions src/scss/components/_progress-indicator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@
display: none;
}
}

@include bem.modifier('mobile-expanded') {
top: 0;
left: 0;
position: fixed;
width: 100%;
height: 100%;
overflow-y: auto;
}
}
}

Expand Down

0 comments on commit b6895ec

Please sign in to comment.