@@ -100,13 +100,20 @@ export function registerTabs(): void {
100
100
// console.log(`[tabStrip.insert] 1 [${parent} > ${child} @${atIndex}] => [${parent.childNodes}]`);
101
101
102
102
const items = tabStrip . items || [ ] ; // Annoyingly, it's the consumer's responsibility to ensure there's an array there!
103
-
104
103
if ( typeof atIndex === 'undefined' || atIndex === items . length ) {
105
104
// console.log(`[tabStrip.insert] 2a [${parent} > ${child} @${atIndex}] => [${parent.childNodes}]`);
106
- tabStrip . items = items . concat ( child . nativeView as TabStripItem ) ;
105
+ tabStrip . _addChildFromBuilder ( ' items' , child . nativeView as TabStripItem ) ;
107
106
} else {
108
107
// console.log(`[tabStrip.insert] 2b [${parent} > ${child} @${atIndex}] => [${parent.childNodes}]`);
109
- tabStrip . items = items . slice ( ) . splice ( atIndex , 0 , child . nativeView as TabStripItem ) ;
108
+ items . forEach ( ( item ) => {
109
+ tabStrip . _removeView ( item ) ;
110
+ } ) ;
111
+ const itemsClone = items . slice ( ) ;
112
+ itemsClone . splice ( atIndex , 0 , child . nativeView as TabStripItem ) ;
113
+ tabStrip . items = itemsClone ;
114
+ itemsClone . forEach ( ( item ) => {
115
+ tabStrip . _addView ( item ) ;
116
+ } ) ;
110
117
}
111
118
} else if ( child . nodeRole === 'item' ) {
112
119
if ( __DEV__ ) {
@@ -122,10 +129,11 @@ export function registerTabs(): void {
122
129
}
123
130
} ,
124
131
remove ( child : NSVElement , parent : NSVElement < TabStrip > ) : void {
125
- const tabs = parent . nativeView ;
132
+ const tabStrip = parent . nativeView ;
126
133
127
134
if ( child . nodeRole === 'items' ) {
128
- tabs . items = ( tabs . items || [ ] ) . filter ( ( i ) => i !== child . nativeView ) ;
135
+ tabStrip . items = ( tabStrip . items || [ ] ) . filter ( ( i ) => i !== child . nativeView ) ;
136
+ tabStrip . _removeView ( child . nativeView ) ;
129
137
} else if ( child . nodeRole === 'item' ) {
130
138
if ( __DEV__ ) {
131
139
warn ( `Unable to remove child "${ child . nativeView . constructor . name } " from <tabStrip> as it had the nodeRole "item"; please correct it to "items".` ) ;
0 commit comments