Skip to content

Commit

Permalink
Merge pull request alibaba-fusion#970 from alibaba-fusion/bugfix/fix_…
Browse files Browse the repository at this point in the history
…editable_tab_focus_lost

fix(Tab): only focus active tab after first render
  • Loading branch information
youluna authored Aug 8, 2019
2 parents cf3ced4 + 909031c commit fe1349e
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/tab/tabs/nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
isTransformSupported,
} from './utils';

const noop = () => {};
const floatRight = { float: 'right', zIndex: 1 };
const floatLeft = { float: 'left', zIndex: 1 };
const { Popup } = Overlay;
Expand Down Expand Up @@ -52,26 +51,21 @@ class Nav extends React.Component {
if (!this.props.animation) {
this.initialSettings();
}

events.on(window, 'resize', this.onWindowResized);
}

componentDidUpdate() {
const ctx = this;
// 此处通过延时处理,屏蔽动画带来的定位不准确问题(由于要支持ie9,因此无法使用transitionend)
clearTimeout(ctx.scrollTimer);
ctx.scrollTimer = setTimeout(() => {
ctx.scrollToActiveTab();
clearTimeout(this.scrollTimer);
this.scrollTimer = setTimeout(() => {
this.scrollToActiveTab();
}, 410); // transition-duration is set to be .4s, wait for the transition finishes before re-calc
clearTimeout(ctx.slideTimer);
ctx.slideTimer = setTimeout(() => {
ctx.setSlideBtn();

clearTimeout(this.slideTimer);
this.slideTimer = setTimeout(() => {
this.setSlideBtn();
}, 200);
if (
this.activeTab &&
findDOMNode(this).contains(document.activeElement)
) {
this.activeTab.focus();
}
}

componentWillUnmount() {
Expand Down Expand Up @@ -393,7 +387,7 @@ class Nav extends React.Component {
const wrapperWH = getOffsetWH(this.wrapper);
const activeTabOffset = getOffsetLT(this.activeTab);
const wrapperOffset = getOffsetLT(this.wrapper);
let target = this.offset;
const target = this.offset;
if (
activeTabOffset >= wrapperOffset + wrapperWH ||
activeTabOffset + activeTabWH <= wrapperOffset
Expand Down

0 comments on commit fe1349e

Please sign in to comment.