mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-12 13:48:35 +02:00
feat: fix keyboard focus between screens
This commit is contained in:
parent
f215980d6c
commit
05d8cfe10c
@ -67,6 +67,7 @@ const stateReducer = (state, message) => {
|
|||||||
|
|
||||||
export const FeedbackWrapper = ({ seedData, open }) => {
|
export const FeedbackWrapper = ({ seedData, open }) => {
|
||||||
const [feedbackIsOpen, setFeedbackIsOpen] = React.useState(open);
|
const [feedbackIsOpen, setFeedbackIsOpen] = React.useState(open);
|
||||||
|
const [manuallyOpened, setManuallyOpened] = React.useState(false);
|
||||||
|
|
||||||
const [state, dispatch] = React.useReducer(
|
const [state, dispatch] = React.useReducer(
|
||||||
stateReducer,
|
stateReducer,
|
||||||
@ -92,8 +93,6 @@ export const FeedbackWrapper = ({ seedData, open }) => {
|
|||||||
console.log('send feedback here ');
|
console.log('send feedback here ');
|
||||||
};
|
};
|
||||||
|
|
||||||
const step1ref = React.useRef(null);
|
|
||||||
|
|
||||||
const visuallyHidden = (stepNumber) => state.currentStep !== stepNumber;
|
const visuallyHidden = (stepNumber) => state.currentStep !== stepNumber;
|
||||||
const isHidden = (stepNumber) =>
|
const isHidden = (stepNumber) =>
|
||||||
!feedbackIsOpen || visuallyHidden(stepNumber);
|
!feedbackIsOpen || visuallyHidden(stepNumber);
|
||||||
@ -131,10 +130,9 @@ export const FeedbackWrapper = ({ seedData, open }) => {
|
|||||||
Very unsatisfied
|
Very unsatisfied
|
||||||
</span>
|
</span>
|
||||||
<span className={styles['satisfaction-input-inputs']}>
|
<span className={styles['satisfaction-input-inputs']}>
|
||||||
{[1, 2, 3, 4, 5].map((n) => (
|
{[1, 2, 3, 4, 5].map((n, i) => (
|
||||||
<span key={`input-group-${n}`}>
|
<span key={`input-group-${n}`}>
|
||||||
<input
|
<input
|
||||||
ref={n === 1 ? step1ref : undefined}
|
|
||||||
className={join(
|
className={join(
|
||||||
'visually-hidden',
|
'visually-hidden',
|
||||||
styles[
|
styles[
|
||||||
@ -154,6 +152,13 @@ export const FeedbackWrapper = ({ seedData, open }) => {
|
|||||||
console.log('the value is', value);
|
console.log('the value is', value);
|
||||||
setNewValue(value);
|
setNewValue(value);
|
||||||
}}
|
}}
|
||||||
|
autoFocus={
|
||||||
|
manuallyOpened
|
||||||
|
? state.data.score
|
||||||
|
? state.data.score === n
|
||||||
|
: i === 0
|
||||||
|
: false
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
className={
|
className={
|
||||||
@ -206,12 +211,7 @@ export const FeedbackWrapper = ({ seedData, open }) => {
|
|||||||
What would you like to see improved in the Unleash
|
What would you like to see improved in the Unleash
|
||||||
documentation?
|
documentation?
|
||||||
</label>
|
</label>
|
||||||
<textarea
|
<textarea id={textareaId} name="" rows="3" autoFocus>
|
||||||
id={textareaId}
|
|
||||||
/* cols="30" */
|
|
||||||
name=""
|
|
||||||
rows="3"
|
|
||||||
>
|
|
||||||
{state.data.comment}
|
{state.data.comment}
|
||||||
</textarea>
|
</textarea>
|
||||||
|
|
||||||
@ -259,16 +259,21 @@ export const FeedbackWrapper = ({ seedData, open }) => {
|
|||||||
>
|
>
|
||||||
<fieldset disabled={hidden}>
|
<fieldset disabled={hidden}>
|
||||||
<span>
|
<span>
|
||||||
Finally, would you mind telling us a little about
|
Finally, are you a paying customer or an open source
|
||||||
yourself? What kind of customer are you?
|
customer of Unleash?
|
||||||
</span>
|
</span>
|
||||||
<div className={styles['customer-type-inputs']}>
|
<div className={styles['customer-type-inputs']}>
|
||||||
{[
|
{[
|
||||||
['a', 'paying', 'paying'],
|
['a', 'paying', 'paying'],
|
||||||
['an', 'open source', 'opensource'],
|
['an', 'open source', 'opensource'],
|
||||||
].map(([article, customerType, key]) => (
|
].map(([article, customerType, key], i) => (
|
||||||
<span key={`input-group-${key}`}>
|
<span key={`input-group-${key}`}>
|
||||||
<input
|
<input
|
||||||
|
autoFocus={
|
||||||
|
state.data.customerType
|
||||||
|
? state.data.customerType === key
|
||||||
|
: i === 0
|
||||||
|
}
|
||||||
id={`customer-type-${key}`}
|
id={`customer-type-${key}`}
|
||||||
className={styles['customer-type-input']}
|
className={styles['customer-type-input']}
|
||||||
name="customer-type"
|
name="customer-type"
|
||||||
@ -326,7 +331,10 @@ export const FeedbackWrapper = ({ seedData, open }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles['user-feedback-container']}>
|
<div className={styles['user-feedback-container']}>
|
||||||
<p>feedback is {feedbackIsOpen ? 'open' : 'closed'}</p>
|
<p>
|
||||||
|
feedback is {feedbackIsOpen ? 'open' : 'closed'}, manually?{' '}
|
||||||
|
{manuallyOpened}
|
||||||
|
</p>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
aria-hidden={feedbackIsOpen}
|
aria-hidden={feedbackIsOpen}
|
||||||
@ -337,7 +345,7 @@ export const FeedbackWrapper = ({ seedData, open }) => {
|
|||||||
disabled={feedbackIsOpen}
|
disabled={feedbackIsOpen}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setFeedbackIsOpen(true);
|
setFeedbackIsOpen(true);
|
||||||
step1ref.current.focus();
|
setManuallyOpened(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span>Feedback</span>
|
<span>Feedback</span>
|
||||||
|
@ -31,9 +31,10 @@
|
|||||||
.user-feedback fieldset {
|
.user-feedback fieldset {
|
||||||
border: none;
|
border: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-feedback > * + * {
|
:is(.user-feedback, .user-feedback fieldset) > * + * {
|
||||||
margin-top: var(--row-gap);
|
margin-top: var(--row-gap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,11 +45,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.user-feedback form {
|
.user-feedback form {
|
||||||
max-width: 850px;
|
/* max-width: 850px; */
|
||||||
|
width: 100%;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
transition: var(--fade-in-transition);
|
transition: var(--fade-in-transition);
|
||||||
/* opacity: 1; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-feedback form > * + * {
|
.user-feedback form > * + * {
|
||||||
@ -229,6 +230,8 @@ button.close-button {
|
|||||||
.form-section-container {
|
.form-section-container {
|
||||||
display: grid;
|
display: grid;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
max-width: 850px;
|
||||||
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-section-container > * {
|
.form-section-container > * {
|
||||||
|
Loading…
Reference in New Issue
Block a user