Skip to content

Commit

Permalink
Merge pull request #841 from Tencent/feat/tabs/enrich-event-params
Browse files Browse the repository at this point in the history
feat(tabs): enrich event params
  • Loading branch information
LeeJim authored Sep 5, 2022
2 parents 26eaeff + f58ac83 commit 78bd600
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/tabs/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ default-value | String / Number | undefined | uncontrolled property。Typescript
name | params | description
-- | -- | --
change | `(value: TabValue, label: string)` | \-
click | `(value: TabValue, label: string)` | \-
scroll | `({ scrollTop: number, isFixed: boolean })` | \-

### TabPanel Props

Expand Down
6 changes: 4 additions & 2 deletions src/tabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ default-value | String / Number | undefined | 激活的选项卡值。非受控

名称 | 参数 | 描述
-- | -- | --
change | `(value: TabValue)` | 激活的选项卡发生变化时触发
scroll | `(detail: { scrollTop: number, isFixed: boolean })` | 滚动时触发,scrollTop: 距离顶部位置,isFixed: 是否吸顶 |
change | `(value: TabValue, label: string)` | 激活的选项卡发生变化时触发
click | `(value: TabValue, label: string)` | 点击 tab 选项卡时触发
scroll | `({ scrollTop: number, isFixed: boolean })` | 页面滚动时触发,scrollTop: 距离顶部位置,isFixed: 是否吸顶

### TabPanel Props

名称 | 类型 | 默认值 | 说明 | 必传
Expand Down
5 changes: 3 additions & 2 deletions src/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,11 @@ export default class Tabs extends SuperComponent {

changeIndex(index) {
const currentTab = this.data.tabs[index];
const { value, label } = currentTab;
if (!currentTab?.disabled && index !== this.data.currentIndex) {
this._trigger('change', { value: currentTab.value });
this._trigger('change', { value, label });
}
this._trigger('click', { value: currentTab.value });
this._trigger('click', { value, label });
}

getAvailableTabIndex(deltaX: number) {
Expand Down

0 comments on commit 78bd600

Please sign in to comment.