Open jscti opened 4 years ago
Found a good solution:
const options: Record<string, any> = {
'distance': 'Distance ascending',
'-price': 'Price ascending',
}
Dialogs.action({
message: 'Sort by',
cancelButtonText: 'Cancel',
actions: Object.values(options),
}).then((result) => {
if (result) {
const key = Object.keys(options).find(key => options[key] === result)
console.log(key);
}
});
Using an actions dialog, the actions list only support a string of arrays .. 2 problems :
Why don't have a basic approach like a good old HTML select option, with both
label: string
andvalue: any
?Actual code, not very happy with it, especially the
action().then
:Code that would be so much better :