diff --git a/src/plugins/crash_reporter/index.js b/src/plugins/crash_reporter/index.js index d485d3350..c63e7ddce 100644 --- a/src/plugins/crash_reporter/index.js +++ b/src/plugins/crash_reporter/index.js @@ -431,12 +431,9 @@ class CrashSelector extends Component { 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); } }} /> diff --git a/src/ui/components/Select.js b/src/ui/components/Select.js index 8fb65f20b..91049e5c9 100644 --- a/src/ui/components/Select.js +++ b/src/ui/components/Select.js @@ -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) => ( - ))}