Skip to content

Commit 65f8359

Browse files
authored
Modal.TopBar - add key to buttons (wix#2237)
1 parent 3838446 commit 65f8359

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/components/modal/TopBar.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ class TopBar extends Component<ModalTopBarProps> {
9999
includeStatusBar: Constants.isIOS
100100
};
101101

102-
renderTopBarButton({onPress, label, icon, accessibilityLabel, buttonProps}: topBarButtonProp) {
102+
renderTopBarButton({onPress, label, icon, accessibilityLabel, buttonProps}: topBarButtonProp, key: string) {
103103
if (onPress && (label || icon)) {
104104
return (
105105
<Button
106+
key={key}
106107
link
107108
onPress={onPress}
108109
label={label}
@@ -126,7 +127,8 @@ class TopBar extends Component<ModalTopBarProps> {
126127
icon: doneIcon,
127128
accessibilityLabel: 'Done',
128129
buttonProps: doneButtonProps
129-
});
130+
},
131+
'done');
130132
}
131133

132134
renderCancel() {
@@ -137,24 +139,25 @@ class TopBar extends Component<ModalTopBarProps> {
137139
icon: cancelIcon,
138140
accessibilityLabel: 'Cancel',
139141
buttonProps: cancelButtonProps
140-
});
142+
},
143+
'cancel');
141144
}
142145

143146
renderLeftButtons = () => {
144147
const {leftButtons} = this.props;
145148
if (_.isArray(leftButtons)) {
146-
return _.map(leftButtons, button => this.renderTopBarButton(button));
149+
return _.map(leftButtons, (button, index) => this.renderTopBarButton(button, `left-${index}`));
147150
} else {
148-
return leftButtons && this.renderTopBarButton(leftButtons);
151+
return leftButtons && this.renderTopBarButton(leftButtons, 'left');
149152
}
150153
};
151154

152155
renderRightButtons = () => {
153156
const {rightButtons} = this.props;
154157
if (_.isArray(rightButtons)) {
155-
return _.map(rightButtons, button => this.renderTopBarButton(button));
158+
return _.map(rightButtons, (button, index) => this.renderTopBarButton(button, `right-${index}`));
156159
} else {
157-
return rightButtons && this.renderTopBarButton(rightButtons);
160+
return rightButtons && this.renderTopBarButton(rightButtons, 'right');
158161
}
159162
};
160163

0 commit comments

Comments
 (0)