Skip to content
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: implement Edit Task Form #6981

Merged
merged 18 commits into from
Feb 12, 2024
Merged

Conversation

shaunanoordin
Copy link
Member

@shaunanoordin shaunanoordin commented Dec 4, 2023

PR Overview

Part of: Pages Editor MVP project and FEM Lab super-project
Follows #6973
Staging branch URL: https://pr-6981.pfe-preview.zooniverse.org/lab/1982/workflows/editor/3711?env=staging

This PR implements the Edit Task Form (the actual interesting bits inside the Edit Step/Page dialog).

  • Currently supports editing: Text Task and Single Question Task
    • Deferred for another PR: Drawing Task
  • Text Task: project owners can edit main text, help text, and is required y/n.
  • Single Question Task: project owners can...
    • edit main text, help text and is required y/n
    • add, edit, and delete choices (Answers)
    • NOT choose the next Step/Page yet. That's for the next PR.

Screenshot: user editing Page P0, Text Task T0

image

Screenshot: user editing Page P0, Single Question Task T0 with 3 choices

image

Status

WIP Ready for review!

Do not merge until 6973 is merged. Currently targets pages-editor-pt11 for reviewing purposes; this will be re-targeted to master when ready.

@coveralls
Copy link

coveralls commented Dec 9, 2023

Coverage Status

coverage: 56.965% (+0.02%) from 56.943%
when pulling 25cee1e on pages-editor-pt12
into 404ec1f on master.

@shaunanoordin shaunanoordin changed the base branch from master to pages-editor-pt11 December 11, 2023 16:09
@shaunanoordin shaunanoordin marked this pull request as ready for review December 11, 2023 16:13
@shaunanoordin
Copy link
Member Author

PR Update

We can now edit Single Question Tasks. This PR is now ready for review!

Copy link
Contributor

@eatyourgreens eatyourgreens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small accessibility problems.

{/* <button>Delete</button> */}
</div>
<div className="input-row">
<label className="big">Choices</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This label isn't linked to a form input.

<div className="input-row">
<label
className="big"
htmlFor={`task-${taskKey}-instruction`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match the id for the text input.

Comment on lines +99 to +110
<label className="narrow">
<input
type="checkbox"
checked={required}
onChange={(e) => {
setRequired(!!e?.target?.checked);
}}
/>
<span>
Required
</span>
</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A11y tip: always use for with labels, as explicit labels are better supported by assistive tech, eg. Dragon Naturally Speaking.
w3c/aria-practices#2870

<ul>
{answers.map(({ label, next }, index) => (
<li
aria-label={`Choice ${index}`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This label should be on the text input, not the list item.

<input type="checkbox" />
Required
<div className="input-row">
<label className="narrow">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add htmlFor to this label too.

@eatyourgreens
Copy link
Contributor

I opened zooniverse/front-end-monorepo#5737 for accessible form labels in the monorepo, but it applies here too.

Copy link
Contributor

@kieftrav kieftrav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - some stylistic suggestions on top of Jim's comments

@@ -123,6 +135,8 @@ export default function TasksPage() {
allTasks={workflow.tasks}
step={workflow.steps[activeStepIndex]}
stepIndex={activeStepIndex}
deleteTask={deleteTask}
updateTask={updateTask}
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stylistic thing to put attributes in alphabetical order

'single': 'Single Question',
'text': 'Text',
}

function EditStepDialog({
allTasks = {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is getting really nit-picky and very personal style... But I like putting the primary / common noun first. For example, tasksAll and taskUpdate. This makes browsing through the code a bit easier to understand.

@@ -28,7 +35,9 @@ function EditStepDialog({
};
});

const title = 'Create a (???) Task'
const firstTask = allTasks?.[taskKeys?.[0]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here... I'd personally prefer taskFirst with tasksAll

@@ -62,13 +71,21 @@ function EditStepDialog({
key={`editTaskForm-${taskKey}`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase and kebab-case mixing

@kieftrav
Copy link
Contributor

@shaunanoordin - PR looks good with a couple minor changes. I did notice an issue with keyboard usage and hitting enter to move the 2nd task to the 3rd task OR the 3rd task to the 2nd task failing. Below is a video of the behavior. This isn't related to this PR but want to note it here as this is where I found it.

pr-review-6981.mov

@shaunanoordin shaunanoordin changed the base branch from pages-editor-pt11 to master February 9, 2024 15:34
@shaunanoordin
Copy link
Member Author

Thanks Jim and Travis!

Required follow up once I get this PR merge train done:

  • fix accessibility issues
  • review code style
  • 🐛 ❗ Examine can't rearrange certain Pages via key issue
  • (from 6973) implement DEFAULT_HANDLER

Merging this first and then moving to 6991

@shaunanoordin shaunanoordin merged commit 0e611cf into master Feb 12, 2024
5 checks passed
@shaunanoordin shaunanoordin deleted the pages-editor-pt12 branch February 12, 2024 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants