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}
|
grow={true}
|
||||||
selected={selectedCrashID || 'NoCrashID'}
|
selected={selectedCrashID || 'NoCrashID'}
|
||||||
options={crashes || {NoCrashID: 'No Crash'}}
|
options={crashes || {NoCrashID: 'No Crash'}}
|
||||||
onChange={(title: string) => {
|
onChangeWithKey={(key: string) => {
|
||||||
for (const key in crashes) {
|
if (onCrashChange) {
|
||||||
if (crashes[key] === title && onCrashChange) {
|
onCrashChange(key);
|
||||||
onCrashChange(key);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -33,8 +33,12 @@ export default class Select extends Component<{
|
|||||||
options: {
|
options: {
|
||||||
[key: string]: string,
|
[key: string]: string,
|
||||||
},
|
},
|
||||||
/** Callback when the selected value changes */
|
/** DEPRECATED: Callback when the selected value changes. The callback is called with the displayed value. */
|
||||||
onChange: (key: string) => void,
|
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 key */
|
||||||
selected?: ?string,
|
selected?: ?string,
|
||||||
/** Label shown next to the dropdown */
|
/** Label shown next to the dropdown */
|
||||||
@@ -45,7 +49,12 @@ export default class Select extends Component<{
|
|||||||
selectID: string = Math.random().toString(36);
|
selectID: string = Math.random().toString(36);
|
||||||
|
|
||||||
onChange = (event: Object) => {
|
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() {
|
render() {
|
||||||
@@ -59,7 +68,7 @@ export default class Select extends Component<{
|
|||||||
className={className}
|
className={className}
|
||||||
value={selected || ''}>
|
value={selected || ''}>
|
||||||
{Object.keys(options).map((key, index) => (
|
{Object.keys(options).map((key, index) => (
|
||||||
<option value={options[key]} key={index}>
|
<option value={key} key={index}>
|
||||||
{options[key]}
|
{options[key]}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user