Skip to content

Commit db5217d

Browse files
author
Oscar Franco
authored
fix: Fix macOS picker not correctly setting controlled value (#194)
1 parent 0f0648a commit db5217d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

js/PickerMacOS.macos.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ const styles = StyleSheet.create({
154154
// The picker will conform to whatever width is given, but we do
155155
// have to set the component's height explicitly on the
156156
// surrounding view to ensure it gets rendered.
157-
height: 20,
157+
height: 24,
158158
},
159159
});
160160

macos/RNCPicker.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ - (instancetype)initWithFrame:(CGRect)frame
2020
{
2121
if ((self = [super initWithFrame:frame pullsDown:false])) {
2222
_color = [NSColor blackColor];
23-
_customFont = [NSFont systemFontOfSize:14];
23+
_customFont = [NSFont systemFontOfSize:14];
2424
_selectedIndex = NSNotFound;
25-
_textAlign = NSTextAlignmentCenter;
25+
_textAlign = NSTextAlignmentCenter;
26+
2627
[self selectItemAtIndex:0];
2728
[[self menu] setFont:_customFont];
2829
self.pullsDown = false;
2930
[self setAction:@selector(mySelector:)];
3031
[self setTarget:self];
31-
3232
}
3333
return self;
3434
}
@@ -54,8 +54,8 @@ - (void)setItems:(NSArray<NSDictionary *> *)items
5454
[row setAttributedTitle:as];
5555
index++;
5656
}
57-
[self setNeedsLayout:true];
5857

58+
[self setNeedsLayout:true];
5959
}
6060

6161

@@ -64,7 +64,7 @@ - (void)setSelectedIndex:(NSInteger)selectedIndex
6464
if (_selectedIndex != selectedIndex) {
6565
_selectedIndex = selectedIndex;
6666
dispatch_async(dispatch_get_main_queue(), ^{
67-
[self setSelectedIndex:selectedIndex];
67+
[self selectItemAtIndex:selectedIndex];
6868
});
6969
}
7070
}

0 commit comments

Comments
 (0)