-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pages Editor: design updates for internal test #7129
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2cd5204
pages-editor-pt26: remove Safari fix which kills other browsers
shaunanoordin 5d0a5ad
TasksPage design: Add New Task button only takes 50% width when workf…
shaunanoordin b42e07a
EditStepDialog design: Done button now has 33% min width
shaunanoordin 2719866
NewTaskDialog design: center-align new Tasks button
shaunanoordin 4a7bcf8
Design: replace light teal with darker teal
shaunanoordin ee6243b
Tasks: add functionality to hide/show Help fields. Add Collapse/Expan…
shaunanoordin 4e9762a
Add collapsible Help field for Drawing and Question Tasks
shaunanoordin 9fd1672
Lab Workflows: set certain projects to use PagesEditor
shaunanoordin 4f000d2
Accessibility: hidden fields now use HTML hidden
shaunanoordin 1d6b945
Accessibility: show/hide Help field button indicates change of state
shaunanoordin f72bb8f
Accessibility: show/hide Help field button indicates change of state
shaunanoordin 8d1be63
Accessibility: show/hide Help field button indicates change of state
shaunanoordin 1f9d10d
Tasks: restyle Help field label
shaunanoordin 46db5b5
Feedback: dynamically alter aria description of show/hide help field …
shaunanoordin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import { useEffect, useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import CollapseIcon from '../../../../../icons/CollapseIcon.jsx'; | ||
import DeleteIcon from '../../../../../icons/DeleteIcon.jsx'; | ||
import ExpandIcon from '../../../../../icons/ExpandIcon.jsx'; | ||
|
||
const DEFAULT_HANDLER = () => {}; | ||
|
||
function TextTask({ | ||
deleteTask = DEFAULT_HANDLER, | ||
isFirstTaskInStep = true, | ||
stepHasManyTasks = false, | ||
task, | ||
taskKey, | ||
|
@@ -31,6 +34,11 @@ function TextTask({ | |
deleteTask(taskKey); | ||
} | ||
|
||
const [ showHelpField, setShowHelpField ] = useState(isFirstTaskInStep || task?.help?.length > 0); | ||
function toggleShowHelpField() { | ||
setShowHelpField(!showHelpField); | ||
} | ||
|
||
// For inputs that don't have onBlur, update triggers automagically. | ||
// (You can't call update() in the onChange() right after setStateValue().) | ||
// TODO: useEffect() means update() is called on the first render, which is unnecessary. Clean this up. | ||
|
@@ -81,14 +89,30 @@ function TextTask({ | |
</span> | ||
</div> | ||
<div className="input-row"> | ||
<label | ||
className="big spacing-bottom-S" | ||
htmlFor={`task-${taskKey}-help`} | ||
> | ||
Help Text | ||
</label> | ||
<div className="flex-row spacing-bottom-S"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd strongly consider refactoring the shared code between DrawingTask / TextTask / QuestionTask into a file called |
||
<label | ||
className="medium" | ||
htmlFor={`task-${taskKey}-help`} | ||
> | ||
Help Text | ||
</label> | ||
<button | ||
aria-label={showHelpField ? 'Hide Help field' : 'Show Help field'} | ||
aria-controls={`task-${taskKey}-help`} | ||
aria-expanded={showHelpField ? 'true' : 'false'} | ||
className="plain" | ||
onClick={toggleShowHelpField} | ||
type="button" | ||
> | ||
{showHelpField | ||
? <CollapseIcon /> | ||
: <ExpandIcon /> | ||
} | ||
</button> | ||
</div> | ||
<textarea | ||
id={`task-${taskKey}-help`} | ||
hidden={!showHelpField} | ||
value={help} | ||
onBlur={update} | ||
onChange={(e) => { setHelp(e?.target?.value) }} | ||
|
@@ -100,6 +124,7 @@ function TextTask({ | |
|
||
TextTask.propTypes = { | ||
deleteTask: PropTypes.func, | ||
isFirstTaskInStep: PropTypes.bool, | ||
stepHasManyTasks: PropTypes.bool, | ||
task: PropTypes.object, | ||
taskKey: PropTypes.string, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default function CollapseIcon({ alt }) { | ||
return ( | ||
<span className="icon fa fa-angle-up" aria-label={alt} role={!!alt ? 'img' : undefined} /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default function ExpandIcon({ alt }) { | ||
return ( | ||
<span className="icon fa fa-angle-down" aria-label={alt} role={!!alt ? 'img' : undefined} /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires the input to be in the DOM at all times. You can’t have a label without its corresponding input in the DOM, so the show/hide pattern used in this PR is broken. It works visually but produces a broken DOM when the text input is removed. That won’t work in a screen reader.
This needs to use a details/summary pattern, or the correct ARIA roles and state for a collapsible panel, in order to work for any users that can't physically see the task editor.
I’d also suggest using the HTML
hidden
boolean attribute to hide the input, rather than removing it from the DOM.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the WAI-ARIA pattern for building a disclosure widget, including roles, states and keyboard interactions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, of course, you could use the native HTML disclosure widget.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scott O'Hara summarised the pros and cons of using a native disclosure widget vs. rolling your own in JavaScript. You can use that to make a decision as to which fits best here.