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

Update: Keep tabs same size when closing (fixes #6088) #6342

Merged
merged 1 commit into from
Jan 23, 2017
Merged

Update: Keep tabs same size when closing (fixes #6088) #6342

merged 1 commit into from
Jan 23, 2017

Conversation

gyandeeps
Copy link
Contributor

@gyandeeps gyandeeps commented Dec 20, 2016

#6088

Same behavior as chrome

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

Test Plan:

  1. open 7-8 tabs (donest matter what the content are)
  2. move your cursor to the close button of the second tab from left
  3. Now as u keep clicking it will maintain the size of the tabs
  4. The size will reset as soon as you move your cursor outside the tab area.

After the change:

tabs

@gyandeeps gyandeeps changed the title Update: Kepp tabs same size when closing (fixes #6088) Update: Keep tabs same size when closing (fixes #6088) Dec 20, 2016
@cezaraugusto cezaraugusto self-assigned this Dec 22, 2016
this.setState({
fixTabWidth: null
})
this.forceUpdate()
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid using forceUpdate() to force re-render, it's ill advised by React itself.

Ref: https://facebook.github.io/react/docs/react-component.html#forceupdate

Normally you should try to avoid all uses of forceUpdate() and only read from this.props and this.state in render().

Could you do it in a way to avoid that? thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have to use forceUpdate here because we inherit from ImmutableComponent and not ReactComponent. ImmutableComponent checks for props only to make the render update work.
forcedUpdate has been used in other places also (possibly because of the above reason).

Copy link
Member

@bsclifton bsclifton Dec 31, 2016

Choose a reason for hiding this comment

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

@gyandeeps the ideal approach would be flux-like and to do the following:

  • store the state in our AppStore / AppState. You can view the current layout of the appState here. We'd want to find a home for the new fixTabWidth value
  • Inside onFrameClose, create and call a new appAction which has should also have an event based name (as opposed to something like setFixTabWidth). onFrameClose seems OK (In the future, other code may want to process on this event)
  • The action then (like other actions) makes a call to dispatcher. This gets handled in appStore.js
  • AppStore then updates the application state
  • main.js should be binding the appState to this control as a property. Here's an example with a different UI control
  • Updating the appState now triggers a re-render

Using the immutable control approach is ideal because components themself don't have state; everything goes through the app store. Even if we insisted on keeping state, it would be better to just change the control to inherit from React.Component

Copy link
Member

@bsclifton bsclifton Dec 31, 2016

Choose a reason for hiding this comment

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

@gyandeeps This is a lot to digest and it's perhaps not the most straight-forward; feel free to hit me up on Slack anytime and we'll work it out 😄

Copy link
Contributor Author

@gyandeeps gyandeeps Dec 31, 2016

Choose a reason for hiding this comment

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

@bsclifton I do understand your approach. I dint do that since this tab width change s such a small state change. It has no impact on the other areas of the application.

Will make the change as you suggested.
Side note: I think in some places i have seen similar (to what i have) approaches taken.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bsclifton Here we need to change the width based on 2 different events. One is when the frame is closed and one onMouseLeave. Any suggestions on what kind of event name you would prefer for latter.

Copy link
Member

Choose a reason for hiding this comment

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

@gyandeeps I think onMouseLeave is appropriate 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why I asked was because onMouseLeave event is very generic looking from a appState perspective.
I can make it specific to tab like onMouseLeaveTab, etc

Copy link
Member

Choose a reason for hiding this comment

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

@gyandeeps ahh- ok gotcha... so yes- I would say an event name which is specific is great. So perhaps onTabClosed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

based on our slack chat, will use onTabClose and onTabMouseLeave as event names.

@gyandeeps
Copy link
Contributor Author

@cezaraugusto @bsclifton I have made changes as suggested. Please review the changes and let me know what u guys think.

@bsclifton bsclifton changed the base branch from master to 0.13.1-branch January 23, 2017 22:09
@bsclifton bsclifton assigned gyandeeps and unassigned cezaraugusto Jan 23, 2017
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

Finally got a chance to go through the code and try this out... well done! 😄 this works great. Thanks! 😄

@bsclifton
Copy link
Member

For some weird reason, I'm not seeing a CI build for this? I'm going to try to submit one manually

@bsclifton bsclifton closed this Jan 23, 2017
@bsclifton bsclifton reopened this Jan 23, 2017
@bsclifton
Copy link
Member

bsclifton commented Jan 23, 2017

Closing/re-opening re-triggered CI build 😄 If tests look good, I'll merge!

@bsclifton
Copy link
Member

Re-ran the tests which failed with CI and all passed except search suggestions (has been failing for a while) and preferences component (the SVG I checked in with #6689 broke this; I'm looking at it now)

Thanks again, @gyandeeps! Merging...

@bsclifton bsclifton merged commit b733ab9 into brave:0.13.1-branch Jan 23, 2017
@gyandeeps gyandeeps deleted the issue6088 branch January 24, 2017 00:43
petemill added a commit to petemill/browser-laptop that referenced this pull request Oct 11, 2017
Fix brave#11434

The tabs are meant to stay the same size until mouseout, according to brave#6088 and implemented in brave#6342. They were sometimes growing (or shrinking) on click and then shrinking further on mouseout due to the size being calculated at the wrong time
syuan100 pushed a commit to syuan100/browser-laptop that referenced this pull request Nov 9, 2017
Fix brave#11434

The tabs are meant to stay the same size until mouseout, according to brave#6088 and implemented in brave#6342. They were sometimes growing (or shrinking) on click and then shrinking further on mouseout due to the size being calculated at the wrong time
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.

4 participants