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

Some small UX fixes for the landing page and dialogs #368

Merged
merged 4 commits into from
May 9, 2018

Conversation

netpro2k
Copy link
Contributor

@netpro2k netpro2k commented May 4, 2018

@cvan
Copy link
Contributor

cvan commented May 7, 2018

animation of <body> background moving when scrolling vertically

nit: I notice that when a modal is opened, the background is scrollable vertically. (I'd add a style like this for when a modal is open: body { overflow: hidden; pointer-events: none; })

I can file this in a follow-up issue, if you'd like. not a biggie.

@cvan cvan self-requested a review May 7, 2018 23:24
Copy link
Contributor

@cvan cvan left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: 0px -> 0

@@ -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">
Copy link
Contributor

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>?

Copy link
Contributor Author

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;
Copy link
Contributor

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;
Copy link
Contributor

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

Copy link
Contributor

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)

}

onKeyPress(e) {
if (e.key === "Escape") {
Copy link
Contributor

@cvan cvan May 7, 2018

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.

image

Copy link
Contributor Author

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.

Copy link
Contributor

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") {

}

componentDidMount() {
window.addEventListener("keypress", this.onKeyPress);
Copy link
Contributor

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.


onKeyPress(e) {
if (e.key === "Escape") {
this.props.onCloseDialog();
Copy link
Contributor

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.

Copy link
Contributor

@cvan cvan left a 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);
Copy link
Contributor

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?

Copy link
Contributor

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)

}

onKeyPress(e) {
if (e.key === "Escape") {
Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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) {
Copy link
Contributor

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants