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

Only update tabPageIndex if user is not hovering other tab #9809

Merged
merged 2 commits into from
Jul 8, 2017

Conversation

cezaraugusto
Copy link
Contributor

@cezaraugusto cezaraugusto commented Jun 30, 2017

Auditors: @bridiver, @NejcZdovc, @bsclifton, @bbondy
Fix #9809
Fix #9895

Reviewer note:

This PR includes work of PR #9896 (first commit). If this PR goes merged without it, please do not squash and I'll close the other. Thanks!

STR:

  1. Set tabs to 6 to make it faster
  2. Open one more to have 2 tab pages
  3. In the last opened tab, visit a slow website (shields on helps), i.e. like wired.com
  4. Before page is loaded, set first tabPage as active.
  5. Hover over a tab
  6. Wait slow website to load (you can't see it but in wired it fully loads after 12 ads blocked)
  7. TabPage should not jump

@cezaraugusto cezaraugusto added this to the 0.18.x (Developer Channel) milestone Jun 30, 2017
@cezaraugusto cezaraugusto self-assigned this Jun 30, 2017
// Otherwise each time the active tab is updated the tabPage
// will be updated as well. While we want that behavior not necessarily
// the user will be on the same tabPage as the active tab. See bug #9779
const isPreviewing = state.get('frames').some(frame => frame.get('hoverState'))
Copy link
Collaborator

@bridiver bridiver Jul 5, 2017

Choose a reason for hiding this comment

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

I think this check should be in updateTabPageIndex to make the functionality consistent wherever it is called, but there are also a few issues here I think. The first one is that we still want to updated the tab page index, but without clearing the previewTabPageIndex, right? If the check is inside updateTabPageIndex that is easily accomplished. The second is that I think we want to check hover state for the tab pages and tabs? The last is that we want to avoid iterating over frames and I can't see any reason to have a per-frame hoverState prop. Can we change it to ['ui', 'tabs, 'hoverTabIndex'] to match hoverTabPageIndex?

Copy link
Collaborator

Choose a reason for hiding this comment

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

actually is it even necessary to clearn previewTabPageIndex inside updateTabPageIndex? I think it's covered by hoverTabPageIndex now. Maybe we can just remove it? The same probably applies to previewFrameKey above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

per-frame hoverState is needed to check whether or not the close tab icon should be shown -- a workaround I did for Aphrodite that can't handle children classes of pseudo-state. Needs to be per-frame.

Are you suggesting to add a new state that checks whether or not a tab is being hovered, like a global clone of hoverState to avoid iterating over frames? I think so but I'm often confused by state names regarding tabs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

When I say we don't need a per-frame value, I'm suggesting that we can have a single key to keep track of which frame is hovered.

frames.1.hoverstate = false
frames.2.hoverstate = true
frames.3.hoverstate = false

changes to ui.tabs.hoverTabIndex = 2

@cezaraugusto cezaraugusto requested a review from bbondy July 7, 2017 19:34
@cezaraugusto cezaraugusto modified the milestones: 0.17.14 (Release Channel), 0.18.x (Beta Channel) Jul 7, 2017
@cezaraugusto
Copy link
Contributor Author

ok feedback addressed, ready for re-review

state = state.deleteIn(['ui', 'tabs', 'previewTabPageIndex'])

return state
// Do not update tabPageIndex if user is in hover mode
Copy link
Member

Choose a reason for hiding this comment

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

Do you know why it even attempts to do this if in hover state mode?

Copy link
Member

Choose a reason for hiding this comment

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

The concern here is that updateTabPageIndex should just do what it says and not ignore for isTabInHoverState.

Instead we should just call updateTabPageIndex when the active state of a tab changes.
Because otherwise you could be on tab page 2 with an active tab on tab page 3. And as you're looking at tab page 2, audio could start playing on tab page 3 and it would change the active tab.

What you did mostly fixes it, but there are some edge cases that are missed.

I posted this issue for tracking the work, I'll merge this in the meantime:
#9911

You can do that task out of line with lower priority.

@bbondy bbondy merged commit e18f2fd into master Jul 8, 2017
bbondy added a commit that referenced this pull request Jul 8, 2017
Only update tabPageIndex if user is not hovering other tab
bbondy added a commit that referenced this pull request Jul 8, 2017
Only update tabPageIndex if user is not hovering other tab
cezaraugusto pushed a commit that referenced this pull request Jul 8, 2017
Only update tabPageIndex if user is not hovering other tab
@cezaraugusto cezaraugusto deleted the tabsbar--9779 branch July 8, 2017 04:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change per-frame hoverState to a single hoverTabIndex key
3 participants