-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Some small UX fixes for the landing page and dialogs #368
Conversation
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.
looks great in Firefox. just need to fix the keypress
event for Chrome (and see my few nits).
many good enhancements here. nice work!
justify-content: center; | ||
margin: 16px 0; | ||
a { | ||
margin: 0px 12px; |
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: 0px
-> 0
src/react-components/info-dialog.js
Outdated
@@ -211,6 +226,18 @@ class InfoDialog extends Component { | |||
<p> | |||
The <b>Bubble Toggle</b> hides avatars that enter your personal space. | |||
</p> | |||
<div className="dialog__box__contents__links"> |
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.
can this be a <p>
or <ul>
?
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.
"everythign is a div" is a hard habbit to break hehe.
@@ -45,7 +45,7 @@ body { | |||
position: fixed; | |||
top: 0; | |||
left: 0; | |||
opacity: 0.66; | |||
opacity: 0.45; |
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.
👍 perfect!
@@ -3,7 +3,7 @@ | |||
height: 100%; | |||
top: 0; | |||
left: 0; | |||
position: absolute; | |||
position: fixed; |
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.
👍 nice, good job fixing this - was on my mental laundry list to file
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.
see my comment here: #368 (comment)
src/react-components/info-dialog.js
Outdated
} | ||
|
||
onKeyPress(e) { | ||
if (e.key === "Escape") { |
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.
can you check document.activeElement.matches("body, a")
? (or you can check e.target
too. there are a couple ways to test this. the a
is because the original footer link still has focus when the click
event has fired to open the modal but the user has not interacted with the page/modal. usually, document.activeElement
would be document.body
.)
in the Get Updates modal, when a user has focused the <input>
field for the email address, pressing the Escape
key should not close the dialog.
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.
Hmm, I am not sure about that one. I would still expect the modal to close even if I was in the textbox if I hit excape. Checking for the "a" doesnt seem right because I could click somewhere inside the dialog and then no longer have an "a" focused.
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.
for accessibility reasons, we try to not hijack keys when form fields are focused. in past projects, we do something like this.
if it's not too much trouble, can you add a tiny helper function to handle this?
var formTags = /input|keygen|meter|option|output|progress|select|textarea/i;
function fieldFocused (e) {
return formTags.test(e.target.nodeName);
}
and then use as such:
if (!fieldFocused(e.target) && e.key === "Escape") {
src/react-components/info-dialog.js
Outdated
} | ||
|
||
componentDidMount() { | ||
window.addEventListener("keypress", this.onKeyPress); |
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.
can you change this to keydown
? it doesn't work in Chrome (tested on macOS).
the keypress
event does fire correctly in both Firefox and Safari. in Chrome, it turns out that the keypress
event is emitted for character keys, but evidently not for such keys as Escape
, ArrowDown
, etc.
src/react-components/info-dialog.js
Outdated
|
||
onKeyPress(e) { | ||
if (e.key === "Escape") { | ||
this.props.onCloseDialog(); |
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.
also, per issue #313 – … or clicking outside the modal
– can you also handle that case? I see that a common convention used for both desktop and touch/mobile sites/apps.
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.
thanks for making the changes! noticed just a few more items. let me know, and I'll re-review it ASAP
} | ||
|
||
componentDidMount() { | ||
window.addEventListener("keydown", this.onKeyDown); |
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.
can you add document.activeElement.blur();
above this line?
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 will reset the focus to document.body
, which is what we'd expect from clicking a modal IMO)
src/react-components/info-dialog.js
Outdated
} | ||
|
||
onKeyPress(e) { | ||
if (e.key === "Escape") { |
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.
for accessibility reasons, we try to not hijack keys when form fields are focused. in past projects, we do something like this.
if it's not too much trouble, can you add a tiny helper function to handle this?
var formTags = /input|keygen|meter|option|output|progress|select|textarea/i;
function fieldFocused (e) {
return formTags.test(e.target.nodeName);
}
and then use as such:
if (!fieldFocused(e.target) && e.key === "Escape") {
@@ -3,8 +3,7 @@ | |||
height: 100%; | |||
top: 0; | |||
left: 0; | |||
position: absolute; | |||
pointer-events: none; | |||
position: fixed; |
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 notice the <body>
scrolling issue (from my GIF) still remains - want me to file a follow-up issue for that?
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.
Yep. I mentioned in slack, the rest of these fixes are clearly minimal impact but I could imagine that one having unintended side-effects since it involves putting pointer-events: none
on the body
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 missed your message, thanks - yeah
} | ||
|
||
onContainerClicked(e) { | ||
if (e.currentTarget === e.target) { |
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 noticed that the Help dialog from a Hub space (e.g., on https://localhost:8080/hub.html?hub_id=0mnu4u5z3q2) does not get closed when clicking outside. can you change this to if (e.target.closest(".dialog-overlay")) {
? (and likely need to move the pointer-events: none
style.)
Esc
key or clicking outside the modal #313)