Skip to content

Applied fixes for disappearing icons. #947

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

Closed
wants to merge 2 commits into from
Closed

Applied fixes for disappearing icons. #947

wants to merge 2 commits into from

Conversation

colshacol
Copy link

@colshacol colshacol commented Jul 5, 2018

Bug Fix

I have been plagued by this bug while working in a Sandbox. Basically, when hovering over a directory, the actionable icons appear. But things get weird when hovering over the icons. In most cases, I hover the icons and they disappear before I get to click, and I have to carefully re-hover the area.

2018-07-04 03 18 38

I spent many hours fighting with this bug, even trying out different libraries and strategic approaches to getting it to stop. Unfortunately, nothing would work.

I got the issue to a less aggravating state with the changes reflected in this PR. (Basically converting showing/hiding of action icons to being handled by CSS purely.) The are now always rendered, but only shown if the <EntryContainer> is in a :hover state.

This leads to less state transitions and icons that are always visible when needed, while invisible when not needed.

2018-07-05 00 16 13

Compared with the first GIF, you can see that the icons still act funky at specific hover points, but do not completely disappear and stay gone when you are hovering.

And here is a detailed preview of the remaining UI buggish-ness.

2018-07-05 00 19 37


  • Documentation N/A
  • Tests N/O
  • Ready to be merged
  • Added myself to contributors table

@@ -36,45 +35,43 @@ function EditIcons({

return (
<div className={className}>
{(hovering || (window.__isTouch && active) || forceShow) && (
Copy link
Author

Choose a reason for hiding this comment

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

Since hovering prop is removed, this entire condition is removed because it is handled above without consideration for hovering.

@@ -36,45 +35,43 @@ function EditIcons({

return (
<div className={className}>
{(hovering || (window.__isTouch && active) || forceShow) && (
<Container>
Copy link
Author

Choose a reason for hiding this comment

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

Also, none of this code has changed. Only the containing {(hovering || .......... && ( ... )} thing was removed.

@@ -179,10 +173,10 @@ class Entry extends React.PureComponent {
{state === '' && (
<Right>
{isMainModule ? (
<span style={{ opacity: hovering ? 1 : 0 }}>main</span>
<span className="mainIndicator">main</span>
Copy link
Author

Choose a reason for hiding this comment

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

Always rendered, but only visible (via CSS) on :hover of EntryContainer.

) : (
<EditIcons
hovering={hovering}
className="actionIcons"
Copy link
Author

Choose a reason for hiding this comment

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

Always rendered, but only visible (via CSS) on :hover of EntryContainer.

@@ -78,6 +78,19 @@ export const getContainerStyles = props => {

export const EntryContainer = styled.span`
${props => getContainerStyles(props)};
.actionIcons,
Copy link
Author

Choose a reason for hiding this comment

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

Here's the magic.

@colshacol
Copy link
Author

@alexvcasillas suggested on Twitter to work it out with pointer-events. So I toyed a bit and came up with a solution to the jittery-ness, as well, and this change is reflected in the latest commit.

I am not sure how this will affect touch screens.

2018-07-05 01 51 23

@alexvcasillas
Copy link
Contributor

alexvcasillas commented Jul 5, 2018 via email

@CompuIves
Copy link
Member

Thanks a lot for the PR! This is very nice!

One thing I'm wondering about is tablets/phones. I think we should show the icons at all times for selected files, because if you're on a tablet you won't know that you can rename/create/etc files otherwise. Unless this already works thanks to the focus property? Maybe we need some testing on this.

@alexvcasillas
Copy link
Contributor

alexvcasillas commented Jul 5, 2018 via email

@colshacol
Copy link
Author

colshacol commented Jul 5, 2018

Here is the required mobile behavior:

  • Directory is open, directory actions are visible.
  • File is focused, file actions are visible. (Or main indicator.)
  • File is focused but directory is closed, all related actions are hidden.

36652831_1976316056011746_4515612990199824384_n

@alexvcasillas
Copy link
Contributor

Awesome job colshacol looks very nice 👌🏻

@colshacol
Copy link
Author

@CompuIves Behavior checks out on mobile.

I'd gladly add some tests, but I don't really see any other tests hanging around. Could you point me in the right direction?

@alexvcasillas
Copy link
Contributor

alexvcasillas commented Jul 6, 2018 via email

@colshacol
Copy link
Author

@alexvcasillas I think the current behavior is great. When the user indicates they are interacting with a folder or file, actions show up. Otherwise, they are not visible. It keeps it from getting too crowded.

And I have manually tested that this is the behavior, even after my changes.

But for actual testing, like unit tests or E2E, I don't recall seeing any other tests sitting anywhere for me to structure mine after.

@CompuIves
Copy link
Member

Heya! I did some testing on mobile and I can't seem to get the behaviour you describe yet (the one where the current directory has icons and the file opened has icons). But it seems like it works in your screenshot, maybe I'm doing something wrong.

But for actual testing, like unit tests or E2E, I don't recall seeing any other tests sitting anywhere for me to structure mine after.

Sorry for that one, we're pretty bad on the testing side :(.

I'm looking forward for merging this in, the new behaviour looks much more solid! Only thing I want to look out for is the icons on mobile, as that is something that people complained about in the past. If we cannot get it done with CSS we may fallback to the JS solution for mobile?

@alexvcasillas
Copy link
Contributor

What's the idea of the JS solution about? Icons are already SVG so they'll look sharp and all that stuff. Can you relate a little more about the issue are people having with mobile?

@CompuIves
Copy link
Member

CompuIves commented Jul 13, 2018

People working on iPads don't want to tap a dir/file twice to do an edit to it in most cases. There are also tablet users that don't know they can rename, edit, etc. the files. Before they had to first click on the file to show the icons, and then click on the icon to edit.

I solved this in JS by adding some logic (if we're on mobile and the file/dir is currently opened: show the icons). I reckon this is hard to implement in CSS, so maybe we could fallback to it when we detect a mobile device.

Or maybe there are better ways?

@alexvcasillas
Copy link
Contributor

We should then detect wheter it's a touch device or not and fix the css by removing all the related :hover selectors so the problem would be easily fixed.

Using styled-components this would be easy since you can interpolate JS expressions to control this within the template literal. I can take a look at this. Is styled-components a thing for this proyect or we should use regular CSS? I can give it a try if you want it but first I have to know the specs on how I'm able to solve this issue.

@colshacol
Copy link
Author

@CompuIves It may be device specific. I can only test on my Galaxy S9 at home. (My method to manually test it is start up the server and then use Seveo to make it available externally so I can connect to it from my phone.)

I am excited to merge this, as well, because it is a problem that bugs the hell out of me and I am proud to have provided a solution instead of just an issue. But I also do not want to break anybody else just to solve my annoyances, haha.

I am thinking that maybe the whole thing could be fixed just by doing the inline-styling for pointer-events in EditIcons.js and leaving the original hovering state. So I will aim to give that a shot today while I'm at work, and I'll see if I can get some of my co-workers to test it on their mobile devices, as well.

@colshacol
Copy link
Author

Also, just saying...

Setting up Zeit Now for auto build on PR would be amazing. Then we could easily share the link for others to view/test on all devices. :)

@lbogdan
Copy link
Contributor

lbogdan commented Jul 13, 2018

We already have this: http://pr947.cs.lbogdan.tk/s/new .

screen shot 2018-07-13 at 22 24 29

@colshacol
Copy link
Author

Ah, very nice!

So, I tried it on 3 other devices and it worked just fine. -- Of course, you have to click "Edit on CodeSandbox" first, because before that you can't perform any actions at all.

@colshacol
Copy link
Author

I finally came to a solution that is just a few lines of CSS after spending hours investigating the issue deeply.

The problem turned out to be this:

screen shot 2018-07-14 at 4 18 07 am

With the tooltip wrapper and inner icon components only being 22px in height, it made losing pointer status on the icon too easy.

When you hovered an icon, the tooltip appeared, but it is rendered outside of this tiny component tree (in a portal) and does not play by the rules set forth in this context.

Upon moving your mouse upwards off the icon, the tooltip fades and slides downwards, causing your mouse to enter that ancestral-cousin tooltip div and leave the directory/file container row div. (i.e mouseLeave -> setState({ hovering: false }))

A refresher of the original issue in action:

2018-07-14 05 01 58

In order to fix it, I found common/components/Tooltip.js inserted global styles related to the tooltip. So I applied pointer-events: none there so I could reach the actual rendered tooltip, rather than the wrapper.

A demo of the resolved issue:

2018-07-14 04 30 48

In order to attempt to fix this without altering functionality, I actually got frustrated and kind of forked the repo all over again. >.> So I can't exactly push to this no-longer-existing branch.

Here are my 2 commits. @CompuIves Would you be fine with me making a separate PR?

cc @alexvcasillas

@CompuIves
Copy link
Member

Ah yes, that seems like the best solution @colshacol. Thanks for looking into this more! Could you open a new PR with that logic? Then I'll merge it in.

Oh, and you can add yourself as contributor by running yarn add-contributor 😄.

@colshacol colshacol mentioned this pull request Jul 15, 2018
4 tasks
@colshacol
Copy link
Author

New PR with CSS-only solution: #964

@colshacol colshacol closed this Jul 15, 2018
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