Skip to content

Commit b8b8bf2

Browse files
rename perviousSelectedTabId to
previousSelectedTabId
1 parent 3a3bdc0 commit b8b8bf2

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,12 @@ instance
524524

525525
```js
526526
const [TabList, PanelList, ready] = useDynTabs({
527-
onSelect: function ({currentSelectedTabId, perviousSelectedTabId}) {
527+
onSelect: function ({currentSelectedTabId, previousSelectedTabId}) {
528528
// you can use 'this' here which refers to the instance
529529
},
530530
});
531531
// or
532-
instance.setOption('onSelect', ({currentSelectedTabId, perviousSelectedTabId}) => {}).refresh();
532+
instance.setOption('onSelect', ({currentSelectedTabId, previousSelectedTabId}) => {}).refresh();
533533
```
534534

535535
### onOpen
@@ -858,7 +858,7 @@ Parameters:
858858

859859
```js
860860
instance.on('onSelect', function (params) {
861-
const {currentSelectedTabId, perviousSelectedTabId} = params;
861+
const {currentSelectedTabId, previousSelectedTabId} = params;
862862
// can use 'this' here which refers to the instance
863863
});
864864
```
@@ -877,7 +877,7 @@ Parameters:
877877
**Example**
878878

879879
```js
880-
instance.one('onSelect', function ({currentSelectedTabId, perviousSelectedTabId}) {
880+
instance.one('onSelect', function ({currentSelectedTabId, previousSelectedTabId}) {
881881
// can use 'this' here which refers to the instance
882882
});
883883
```
@@ -897,7 +897,7 @@ Parameters:
897897

898898
```js
899899
const onSelectHandler = function (params) {
900-
const {currentSelectedTabId, perviousSelectedTabId} = params;
900+
const {currentSelectedTabId, previousSelectedTabId} = params;
901901
// can use 'this' here which refers to the instance
902902
this.off('onSelect', onSelectHandler);
903903
};
@@ -1023,6 +1023,8 @@ const open_tab_3 = function () {
10231023
};
10241024
```
10251025

1026+
- First parameter of onSelect function is an object and has perviousSelectedTabId property which is deprecated. you should use previousSelectedTabId property instead of perviousSelectedTabId property.
1027+
10261028
## Test
10271029

10281030
```js

example/basic/com/basic/service/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default {
3535
const context = this;
3636
return true;
3737
},
38-
onSelect: ({currentSelectedTabId, perviousSelectedTabId}) => {
38+
onSelect: ({currentSelectedTabId, previousSelectedTabId}) => {
3939
const context = this;
4040
},
4141
beforeClose: function (e, id) {

src/index.test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,16 @@ describe('select method : ', () => {
191191
expect(op.onInit.mock.calls.length === 2).toBe(true);
192192
expect(op.onChange.mock.calls.length === 1).toBe(true);
193193
expect(op.onSelect.mock.calls.length === 1).toBe(true);
194-
expect(op.onSelect.mock.calls[0][0]).toEqual({currentSelectedTabId: '2', perviousSelectedTabId: '1'});
195-
expect(onSelect.mock.calls[0][0]).toEqual({currentSelectedTabId: '2', perviousSelectedTabId: '1'});
194+
expect(op.onSelect.mock.calls[0][0]).toEqual({
195+
currentSelectedTabId: '2',
196+
perviousSelectedTabId: '1',
197+
previousSelectedTabId: '1',
198+
});
199+
expect(onSelect.mock.calls[0][0]).toEqual({
200+
currentSelectedTabId: '2',
201+
perviousSelectedTabId: '1',
202+
previousSelectedTabId: '1',
203+
});
196204
expect(op.onInit).toHaveBeenCalledBefore(op.onChange);
197205
expect(op.onChange).toHaveBeenCalledBefore(op.onSelect);
198206
expect(op.onSelect).toHaveBeenCalledBefore(onSelect);

src/utils/api/api.factory.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ Helper.setNoneEnumProps(_apiProps, {
180180
isSwitched &&
181181
this.trigger('onSelect', this.userProxy, {
182182
currentSelectedTabId: newState.selectedTabID,
183+
previousSelectedTabId: oldState.selectedTabID,
183184
perviousSelectedTabId: oldState.selectedTabID,
184185
});
185186
}

0 commit comments

Comments
 (0)