-
Notifications
You must be signed in to change notification settings - Fork 71
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
Clean up studio edit template #88
Conversation
@@ -222,6 +242,7 @@ | |||
display: none; | |||
} | |||
.xblock--drag-and-drop--editor .items-form .row.advanced-link { | |||
cursor: pointer; |
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 is because the <a>
element has no href=""
attribute, right? Is it better to do this or use href="#"
+ preventDefault()
?
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.
Yes, that's right. I removed href="#"
and added this CSS rule. I believe this is considered to be a better approach than href="#"
, which has always felt like a hack to me.
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.
Instead of using an a-tag, you should use a button. A-tag elements should take you someplace, whereas buttons do actions. Buttons give you the correct a11y behavior, whereas you have to manually create those behaviors with other elements using aria properties.
Tabbing through the Studio editing UI, I don't see any way to even get to these "Remove" links with the keyboard. Buttons will be part of the tab order.
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.
@cahrens Thanks, thanks makes sense. I replaced <a>
elements with <button>
s.
@mtyaka Just a few minor notes/questions - thanks for this! |
@bradenmacdonald Thanks for the review! Your comments have been addressed. |
👍 Nice improvement, @mtyaka.
|
# of the DnDv2 block on the same page sharing the same ID values. | ||
# We avoid using ID attributes in preference to classes, but sometimes we still need IDs to | ||
# connect 'for' and 'aria-describedby' attributes to the associated elements. | ||
id_suffix = uuid.uuid4().hex[:16] |
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.
Another way of creating unique IDs is to incorporate the XBlock id. That's what we do for capa and ORA.
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.
@cahrens Thanks for the hint. I replaced uuid.uuid4()
with block.location.html_id()
. I was not aware of the html_id()
function before.
I would suggest a doc review of the field help text; it's pretty inconsistent in formatting and style. Who is the edX doc person working on Drag and Drop? |
# We avoid using ID attributes in preference to classes, but sometimes we still need IDs to | ||
# connect 'for' and 'aria-describedby' attributes to the associated elements. | ||
id_suffix = uuid.uuid4().hex[:16] | ||
js_templates = js_templates.replace('{{id_suffix}}', id_suffix) | ||
context = { |
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.
Why are you directly replacing id_suffix on line 224 in js_templates (I'm not sure how those are used) and also passing id_suffix in the context (which is what I would expect)?
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.
@cahrens js_templates contains Handlebars templates. Replacing id_suffix
with raw string substitutions is a bit of a hack, however I think it's still better than passing the id_suffix
variable to JavaScript and making sure it is present in the handlebars context every time when rendering a handlebars template.
We still have to pass the id_suffix
variable in the context, because we use it inside django templates, too.
^ @pdesjardins is doing docs for drag and drop |
@@ -254,14 +275,15 @@ | |||
} | |||
|
|||
.xblock--drag-and-drop--editor .remove-zone { | |||
cursor: pointer; |
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.
Same note here-- don't use a-tags.
<label class="h3"> | ||
<span>{% trans fields.item_background_color.display_name %}</span> | ||
<input class="item-background-color" | ||
placeholder="{% blocktrans with example1='blue' example2='#0000ff' %}e.g. {{example1}} or {{example2}}{% endblocktrans %}" |
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.
Again, avoid placeholders.
There are some good improvements here! However, there is still more work to do to make the Studio UI accessible. I'm sure a full a11y review will find things I have missed, but for now, try accessing everything in the UI just with just the keyboard-- there are several elements that one cannot currently navigate to (specifically, there are many problematic a-tags that are acting as buttons). |
I will wait to review in depth until updates are made per @cahrens comments |
<label for="display-borders">{% trans "Display zone borders on the image" %}:</label> | ||
<input name="display-borders" id="display-borders" type="checkbox" /> | ||
<label> | ||
<span>{% trans "Display zone borders on the image" %}:</span> |
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.
Another color take a look at @cahrens comment above
👍 |
This is looking a lot better! Make sure that when a button is clicked, the focus goes someplace sensible. For instance, when clicking "Add an Item", focus should move to the newly created Item. I also find it odd that when focus is on a button (both "Add an Item" and the Delete buttons), they actually look disabled. |
Thanks @cahrens, I addressed most of your comments:
That button HTML code was copied from the Studio (CAPA problems currently also use
A review of the CSS would be great, but I think it would be best if it was done outside of this PR (reviewing all CSS, not just the changes in this PR). |
I understand about the Continue/Cancel buttons. When Studio was written we incorrectly used a-tags everywhere, and that is something that will be cleaned up later this year. I agree it makes sense to wait until those fixes are done. However, when I tab to the Continue button and press Enter, focus is remaining in the button bar-- I think this is new behavior since yesterday. After Continue, keyboard focus needs to move to the top of the new settings panel. As it is, it is very easy to move keyboard focus outside of the dialog entirely (while tabbing to try to figure out where focus is), and difficult to figure out how to get back. Also a nit about adding a little padding around this close button: |
The behavior was not new, but I should have realized and fixed it after your previous comment, sorry I missed that. It's fixed in the latest update.
Last commit adds a bit of extra padding on small screens. I updated the sandbox with latest changes. |
scope=Scope.settings, | ||
default=1, | ||
) | ||
|
||
item_background_color = String( | ||
display_name=_("Item background color"), | ||
help=_("The background color of draggable items in the problem."), | ||
help=_("The background color of draggable items in the problem (e.g. 'blue' or '#0000ff')."), |
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.
Nit: Should we use "example" instead of e.g.? I am not sure how well e.g. translates.
The rest looks good to me for the context of the story. 👍 Pending @cahrens comments being resolved. |
@@ -137,6 +140,7 @@ function DragAndDropEditBlock(runtime, element, params) { | |||
$fbkTab.addClass('hidden'); | |||
$zoneTab.removeClass('hidden'); | |||
self.scrollToTop(); | |||
$zoneTab.find('input:first').select(); | |||
|
|||
$(this).one('click', function loadThirdTab(e) { |
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.
I believe there are preventDefault calls you can remove in this file (and perhaps others) now that the a-tags have been converted to buttons.
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.
👍 It would be good to remove the unneeded event.preventDefault() calls, but I don't need to take a look at this again. |
- Use field.display_name instead of hardcoding field names in the template. - Display help text under each field instead of putting it in the title attribute.
ID attributes have to be unique on the document level. To avoid accidentaly having multiple elements with the same ID, we prefer to use class attributes. There are two situations where we still need an ID attribute: - Connecting <label> elements to the associated input element using the 'for' attribute - Connecting description of an element with the 'aria-describedby' attribute. In the first case, we can often wrap the associated input inside the <label> tag, so that we don't need IDs, although in some cases that is not possible because it breaks the layout. In cases when we still need to use ID attributes, we append a random string to ensure uniqueness.
- Change a elements to buttons. - Don't use placedholers. - Make font sizes more consistent. - Fix color contrasts. - Use location.html_id() built-in function.
The button would be too close to the input field on small screens.
- i18n: Use "example" instead of "e.g." - No need to "preventDefault" for clickable elements that are now <button>s
0af3fc3
to
eca2554
Compare
Rebased 0af3fc3 onto master. |
@staubina @cahrens Thanks again for the review. Comments addressed (aside from the one about moving focus that you said could be handled as part of the a11y review, @cahrens). @cptvitamin @clrux I've added this story to the a11y review ticket for DnDv2.1 (SOL-1978) so you can have a look at it together with the other DnDv2.1 features. (My bandwidth for working on this PR is limited this week, and since it builds on some DnDv2.1 stories that were already part of SOL-1978, it makes sense to add this PR to the combined review.) @sstack22 This is ready for you, please have a look. |
Looks great, 👍 on my end. Two small nits: capitalization is a bit inconsistent (Final Feedback vs. Item description, as an example). I would also suggest removing the Note at the top of the Studio Editor - I'm concerned about course teams being prompted to delete problems. As this is outside the scope of this PR, I'm fine with this being addressed separately. |
@sstack22 Thanks for the review! Merging the PR now. Re: your comments about inconsistent capitalization and removing the "Note", I'll see with @bradenmacdonald whether/how we can incorporate those into the work that's left for the DnDv2.1 epic. |
Description:
This PR cleans up the Studio edit template and associated JS code to:
field.display_name
values for field labels instead of hardcoding/duplicating the names in the template.title
and<span class="sr">
.id
attributes withclass
-es. In cases where that is not possible, ensure that theid
attributes are globally unique.<button>
elements instead of<a>
elements for buttons.Screenshots:
Before:
After:
JIRA ticket: https://openedx.atlassian.net/browse/SOL-1990
Dependencies: None
Discussions: #77 (comment)
Sandbox URLs (installed version 9845083):
You are probably mostly interested in the Studio edit functionality. Some DnDv2 blocks can be edited at: http://studio-dndv2-sandbox5.opencraft.hosting/container/block-v1:OpenCraftX+OC1+1+type@vertical+block@e3c62b19090948b8ad89d3386bff4435
Testing Instructions:
This PR does not implement any new functionality, so there is no specific feature to test.
The important thing is to ensure that the studio edit functionality continues to look and function correctly.
Reviewers:
a11y: @edx/edx-accessibilityScheduled combined review for all DnDv2.1 stories: SOL-1978