Fix the bug related to the crash selection
Summary:
Fixes the bug when the crash options had same title. Selection was broken in that case. Look at the video.
{F163450316}
Reviewed By: jknoxville
Differential Revision: D15985919
fbshipit-source-id: 7366c8f5f33bbddc15c058b7d20d78d295161404
This commit is contained in:
committed by
Facebook Github Bot
parent
c38a55d98f
commit
81b71352dd
@@ -431,12 +431,9 @@ class CrashSelector extends Component<CrashSelectorProps> {
|
||||
grow={true}
|
||||
selected={selectedCrashID || 'NoCrashID'}
|
||||
options={crashes || {NoCrashID: 'No Crash'}}
|
||||
onChange={(title: string) => {
|
||||
for (const key in crashes) {
|
||||
if (crashes[key] === title && onCrashChange) {
|
||||
onCrashChange(key);
|
||||
return;
|
||||
}
|
||||
onChangeWithKey={(key: string) => {
|
||||
if (onCrashChange) {
|
||||
onCrashChange(key);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -33,8 +33,12 @@ export default class Select extends Component<{
|
||||
options: {
|
||||
[key: string]: string,
|
||||
},
|
||||
/** Callback when the selected value changes */
|
||||
onChange: (key: string) => void,
|
||||
/** DEPRECATED: Callback when the selected value changes. The callback is called with the displayed value. */
|
||||
onChange?: (value: string) => void,
|
||||
|
||||
/** Callback when the selected value changes. The callback is called with the key for the displayed value */
|
||||
onChangeWithKey?: (key: string) => void,
|
||||
|
||||
/** Selected key */
|
||||
selected?: ?string,
|
||||
/** Label shown next to the dropdown */
|
||||
@@ -45,7 +49,12 @@ export default class Select extends Component<{
|
||||
selectID: string = Math.random().toString(36);
|
||||
|
||||
onChange = (event: Object) => {
|
||||
this.props.onChange(event.target.value);
|
||||
if (this.props.onChangeWithKey) {
|
||||
this.props.onChangeWithKey(event.target.value);
|
||||
}
|
||||
if (this.props.onChange) {
|
||||
this.props.onChange(this.props.options[event.target.value]);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
@@ -59,7 +68,7 @@ export default class Select extends Component<{
|
||||
className={className}
|
||||
value={selected || ''}>
|
||||
{Object.keys(options).map((key, index) => (
|
||||
<option value={options[key]} key={index}>
|
||||
<option value={key} key={index}>
|
||||
{options[key]}
|
||||
</option>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user