Skip to content

Commit

Permalink
fix Your role focus and back button to Who is your question about
Browse files Browse the repository at this point in the history
  • Loading branch information
ediiotero committed Nov 27, 2024
1 parent 817e529 commit 4b19202
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/applications/ask-va/components/ProgressBar.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import scrollTo from 'platform/utilities/ui/scrollTo';
import { focusElement } from 'platform/utilities/ui';
import { CHAPTER_1, CHAPTER_2, CHAPTER_3 } from '../constants';
import {
aboutMyselfRelationshipVeteranPages,
Expand Down Expand Up @@ -69,6 +70,7 @@ const ProgressBar = ({ pathname }) => {
() => {
// Scroll back to the top of the form
scrollTo('topScrollElement');
focusElement('h2');
setViewedPages([...viewedPages, currentPath]);

if (!viewedPages.includes(currentPath) && percent < 100) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@ import { connect } from 'react-redux';
import FormNavButtons from '~/platform/forms-system/src/js/components/FormNavButtons';
import RequireSignInModal from '../components/RequireSignInModal';
import SignInMayBeRequired from '../components/SignInMyBeRequired';
import { flowPaths } from '../config/schema-helpers/formFlowHelper';
import {
CategoryEducation,
CHAPTER_2,
CHAPTER_3,
whoIsYourQuestionAboutLabels,
} from '../constants';
import { CHAPTER_2, whoIsYourQuestionAboutLabels } from '../constants';

const WhoIsYourQuestionAboutCustomPage = props => {
const { onChange, loggedIn, goBack, goToPath, formData } = props;
const { onChange, loggedIn, goBack, formData, goForward } = props;
const [validationError, setValidationError] = useState(null);
const [showModal, setShowModal] = useState({ show: false, message: '' });

Expand All @@ -35,21 +29,14 @@ const WhoIsYourQuestionAboutCustomPage = props => {

const showError = data => {
if (data.whoIsYourQuestionAbout) {
if (
data.selectCategory !== CategoryEducation &&
data.whoIsYourQuestionAbout !== whoIsYourQuestionAboutLabels.GENERAL
) {
return goToPath(`/${CHAPTER_3.RELATIONSHIP_TO_VET.PATH}`);
}
return goToPath(`/${flowPaths.general}-1`);
goForward(data);
}
focusElement('va-radio');
return setValidationError('Please select who your question is about');
};

const handleChange = event => {
const selectedValue = event.detail.value;
onChange({ ...formData, whoIsYourQuestionAbout: selectedValue });
if (
!loggedIn &&
(selectedValue === whoIsYourQuestionAboutLabels.MYSELF ||
Expand Down Expand Up @@ -90,7 +77,7 @@ const WhoIsYourQuestionAboutCustomPage = props => {
name="who-is-your-question-about"
label={option.label}
value={option.label}
checked={formData.whoIsYourQuestionAbout === option.value}
checked={formData.whoIsYourQuestionAbout === option.label}
aria-describedby={
formData.whoIsYourQuestionAbout === option.value
? option.value
Expand All @@ -117,7 +104,7 @@ WhoIsYourQuestionAboutCustomPage.propTypes = {
value: PropTypes.string,
onChange: PropTypes.func,

Check warning on line 105 in src/applications/ask-va/containers/WhoIsYourQuestionAboutCustomPage.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/ask-va/containers/WhoIsYourQuestionAboutCustomPage.jsx:105:3:Callback prop types must be listed after all other prop types

Check warning on line 105 in src/applications/ask-va/containers/WhoIsYourQuestionAboutCustomPage.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/ask-va/containers/WhoIsYourQuestionAboutCustomPage.jsx:105:3:Callback prop types must be listed after all other prop types

Check warning on line 105 in src/applications/ask-va/containers/WhoIsYourQuestionAboutCustomPage.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/ask-va/containers/WhoIsYourQuestionAboutCustomPage.jsx:105:3:Callback prop types must be listed after all other prop types
goBack: PropTypes.func,
goToPath: PropTypes.func,
goForward: PropTypes.func,
formData: PropTypes.shape({
whoIsYourQuestionAbout: PropTypes.string,
}),
Expand Down

0 comments on commit 4b19202

Please sign in to comment.