Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Switch tabs onmousedown #124

Merged
merged 9 commits into from
Mar 18, 2015
Merged

Switch tabs onmousedown #124

merged 9 commits into from
Mar 18, 2015

Conversation

martpie
Copy link
Contributor

@martpie martpie commented Mar 16, 2015

following #123

I tested it, It works quite well and feels more reactive. Merge if you feel the need.

@thomasjo
Copy link
Contributor

@KeitIG You've got a broken spec which needs to be fixed:
https://travis-ci.org/atom/tabs/builds/54543728#L111

@martpie
Copy link
Contributor Author

martpie commented Mar 16, 2015

@thomasjo

I got the error, (conflict between two mousedown events). Is it possible to test Travis builds without committing to avoit commits pollution ?

@martpie
Copy link
Contributor Author

martpie commented Mar 16, 2015

now done. 630883e was more a code cleanup than a spec fix.

@as-cii
Copy link
Contributor

as-cii commented Mar 16, 2015

@KeitIG thank you for taking the time to contribute! 🙇

I quickly tested it and, apparently, dragging tabs is not working anymore. My first concern is that specs are not failing, probably because we fake the drag event when testing this behavior.

Moreover, UX-wise, I do have one more concern: what would happen if I simply want to drag a tab which is not currently open? This way we would always open the tab, even if the user didn't want to. Personally, I would find this a bit confusing but I am not sure it's wrong either.

@kevinsawicki: what do you think?

@martpie
Copy link
Contributor Author

martpie commented Mar 16, 2015

@as-cii Yep, got the bug too. I may have an idea about why.

On the UX part, looking at Sublime, imagine you'are at tabs[0], if you want to place tabs[1] before tabs[0], tabs[1] is opened when it gets the mousedown event.

I'd be curious what other people are thinking about this.

@winstliu
Copy link
Contributor

@as-cii This is how Chrome does it, but it does feel a bit weird when you didn't actually want the tab to open.

@simurai
Copy link
Contributor

simurai commented Mar 17, 2015

I like it. It feels a bit more "effortless".

@as-cii what would happen if I simply want to drag a tab which is not currently open? This way we would always open the tab, even if the user didn't want to.

Currently if you drag a not opened tab, it still opens that tab on mouseup. So it's currently not possible to drag without opening.

And I'm not sure which is the better behaviour. Sometimes you want to drag + edit a closed tab and therefore having it open without an extra click, is nice too.

as-cii and others added 4 commits March 17, 2015 11:15
* ✅ Document right-click (and ctrlKey) behavior
Avoid opening a tab on ctrl-left click
On `mousedown` our production code prevented the default browser behavior. This,
however, was not documented in our tests: for instance, specs were green even if
dragging was not working anymore.
Since writing an integration test or simulating a drag event in the current suite was quite painful, I opted to spy on `event.preventDefault` and ensure
that it was called appropriately to preserve our dragging behavior.

* 🎨 Move event helpers out of tabs-spec.coffee
@as-cii
Copy link
Contributor

as-cii commented Mar 17, 2015

Currently if you drag a not opened tab, it still opens that tab on mouseup. So it's currently not possible to drag without opening.

@simurai: nice observation! For some reason I assumed that the mouseup event was not fired whenever a drag occurred. Since we're basically preserving the original behavior I think we can merge this after refining it a bit.

@KeitIG: I opened another pull-request on your fork to shield us from the dragging regression in the future.

As I described there, writing an integration test (e.g. through a web driver) was not an option, and simulating the dragging events through a series of mousedown, mousemove and mouseup events was not really straightforward as we had to deal with positions. Therefore, I opted to go with a unit test which ensures that event.preventDefault gets called only when appropriate.

/cc: @kevinsawicki

Add missing specs for event.preventDefault()
@kevinsawicki
Copy link
Contributor

So this is ready to go?

@martpie
Copy link
Contributor Author

martpie commented Mar 18, 2015

I guess so, as-cii have done a nice job. (Thanks btw, I would not have figured it out myself)

as-cii added a commit that referenced this pull request Mar 18, 2015
@as-cii as-cii merged commit f0839f0 into atom:master Mar 18, 2015
@as-cii
Copy link
Contributor

as-cii commented Mar 18, 2015

@kevinsawicki: yep! I have just merged it 👍

@KeitIG: thank you for this great contribution! ✨

@martpie martpie deleted the switch-tab-mousedown branch April 20, 2015 08:24
@izuzak
Copy link
Contributor

izuzak commented May 27, 2015

@as-cii @KeitIG I think this PR broke some focus-related things when switching tabs -- see atom/atom#6662 for details. Specifically, I think 6cb57b8 might be responsible. Could you take a look and double-check? 🍩

@martpie
Copy link
Contributor Author

martpie commented May 28, 2015

Indeed, It may be due to that, looking for a way to rewrite this.

edit: Changing to return false does fix the problem, but break drag&drop (event dragstart is not fired). Looking for a way to trigger it anyway, if you have any idea...

@nathansobo
Copy link
Contributor

@KeitIG You might try calling activate on the associated pane at the model level once a new pane is selected. That should instruct the pane view to focus its contents again and might work. I don't have deep insight into what's going on but that could be a helpful tool.

@nathansobo
Copy link
Contributor

Nevermind, I see activate is already being called and somehow focus is still getting stolen.

nathansobo pushed a commit that referenced this pull request May 28, 2015
Fixes atom/atom#6662
Refs #124

This was introduced in 310c058, with
a description that it prevented focus from being stolen when the close
icon is clicked. I don’t really understand the reasoning there, and
removing it fixes the above issue and doesn’t seem to introduce any
problems with focus on clicking the close icon.

@kevinsawicki perhaps you can comment on whether this makes sense?
@nathansobo
Copy link
Contributor

I've opened a PR which you can see above which fixes the issue for me. @izuzak want to give it a spin and see if it breaks anything else. I couldn't find anything but I'm a sucky QA tester.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants