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

Revert "Fix tabs briefly animating too wide after finishing closing some tabs" #12718

Merged
merged 1 commit into from
Jan 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions app/renderer/components/tabs/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,29 @@ class Tab extends React.Component {
return props
}

componentWillReceiveProps (nextProps) {
if (this.props.tabWidth && !nextProps.tabWidth) {
// remember the width so we can transition from it
this.originalWidth = this.elementRef.getBoundingClientRect().width
}
}

componentDidUpdate (prevProps) {
if (prevProps.tabWidth && !this.props.tabWidth) {
window.requestAnimationFrame(() => {
const newWidth = this.elementRef.getBoundingClientRect().width
this.elementRef.animate([
{ flexBasis: `${this.originalWidth}px`, flexGrow: 0, flexShrink: 0 },
{ flexBasis: `${newWidth}px`, flexGrow: 0, flexShrink: 0 }
], {
duration: 250,
iterations: 1,
easing: 'ease-in-out'
})
})
}
}

render () {
// we don't want themeColor if tab is private
const isThemed = !this.props.isPrivateTab && this.props.isActive && this.props.themeColor
Expand All @@ -311,17 +334,16 @@ class Tab extends React.Component {
(this.isDraggingOverRight && !this.isDraggingOverSelf) && styles.tabArea_dragging_right,
this.isDragging && styles.tabArea_isDragging,
this.props.isPinnedTab && styles.tabArea_isPinned,
(this.props.partOfFullPageSet || !!this.props.tabWidth) && styles.tabArea_partOfFullPageSet,
this.props.tabWidth && styles.tabArea_forcedWidth
(this.props.partOfFullPageSet || !!this.props.tabWidth) && styles.tabArea_partOfFullPageSet
)}
style={this.props.tabWidth ? { flex: `0 0 ${this.props.tabWidth}px` } : {}}
onMouseMove={this.onMouseMove}
onMouseEnter={this.onMouseEnter}
onMouseLeave={this.onMouseLeave}
data-test-id='tab-area'
data-frame-key={this.props.frameKey}
ref={elementRef => { this.elementRef = elementRef }}
style={this.props.tabWidth ? { '--tab-forced-width': `${this.props.tabWidth}px` } : { }}
>
>
{
this.props.isActive && this.props.notificationBarActive
? <NotificationBarCaret />
Expand Down Expand Up @@ -392,8 +414,8 @@ const styles = StyleSheet.create({
verticalAlign: 'top',
overflow: 'hidden',
height: '-webkit-fill-available',
flex: '1 1 0',
transition: 'flex .45s ease',
flex: 1,

// no-drag is applied to the button and tab area
// ref: tabs__tabStrip__newTabButton on tabs.js
WebkitAppRegion: 'no-drag',
Expand Down Expand Up @@ -425,11 +447,6 @@ const styles = StyleSheet.create({
maxWidth: 'initial'
},

tabArea_forcedWidth: {
flex: '0 0 var(--tab-forced-width)',
transitionDuration: '0s'
},

tabArea__tab: {
borderWidth: '0 1px 0 0',
borderStyle: 'solid',
Expand Down