From 05d8cfe10c08f4cd1a5360fc7c5b1f49005b27b0 Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Mon, 28 Feb 2022 22:09:18 +0100 Subject: [PATCH] feat: fix keyboard focus between screens --- website/src/components/UserFeedback/index.jsx | 38 +++++++++++-------- .../components/UserFeedback/styles.module.css | 9 +++-- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/website/src/components/UserFeedback/index.jsx b/website/src/components/UserFeedback/index.jsx index b2f60cc992..fe8bdcc5e0 100644 --- a/website/src/components/UserFeedback/index.jsx +++ b/website/src/components/UserFeedback/index.jsx @@ -67,6 +67,7 @@ const stateReducer = (state, message) => { export const FeedbackWrapper = ({ seedData, open }) => { const [feedbackIsOpen, setFeedbackIsOpen] = React.useState(open); + const [manuallyOpened, setManuallyOpened] = React.useState(false); const [state, dispatch] = React.useReducer( stateReducer, @@ -92,8 +93,6 @@ export const FeedbackWrapper = ({ seedData, open }) => { console.log('send feedback here '); }; - const step1ref = React.useRef(null); - const visuallyHidden = (stepNumber) => state.currentStep !== stepNumber; const isHidden = (stepNumber) => !feedbackIsOpen || visuallyHidden(stepNumber); @@ -131,10 +130,9 @@ export const FeedbackWrapper = ({ seedData, open }) => { Very unsatisfied - {[1, 2, 3, 4, 5].map((n) => ( + {[1, 2, 3, 4, 5].map((n, i) => ( { console.log('the value is', value); setNewValue(value); }} + autoFocus={ + manuallyOpened + ? state.data.score + ? state.data.score === n + : i === 0 + : false + } /> - @@ -259,16 +259,21 @@ export const FeedbackWrapper = ({ seedData, open }) => { >
- Finally, would you mind telling us a little about - yourself? What kind of customer are you? + Finally, are you a paying customer or an open source + customer of Unleash?
{[ ['a', 'paying', 'paying'], ['an', 'open source', 'opensource'], - ].map(([article, customerType, key]) => ( + ].map(([article, customerType, key], i) => ( { return (
-

feedback is {feedbackIsOpen ? 'open' : 'closed'}

+

+ feedback is {feedbackIsOpen ? 'open' : 'closed'}, manually?{' '} + {manuallyOpened} +