Skip to content

Commit

Permalink
replace key with id
Browse files Browse the repository at this point in the history
  • Loading branch information
noraleonte committed May 3, 2024
1 parent 5d44a4d commit 820c4b9
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ interface PickersShortcutsItemGetValueParams<TValue> {
export interface PickersShortcutsItem<TValue> {
label: string;
getValue: (params: PickersShortcutsItemGetValueParams<TValue>) => TValue;
key?: string;
/**
* Identifier of the shortcut.
* If provided, it will be used as the key of the shortcut.
*/
id?: string;
}

export type PickersShortcutsItemContext = Omit<PickersShortcutsItem<unknown>, 'getValue'>;
Expand Down Expand Up @@ -65,7 +69,7 @@ function PickersShortcuts<TValue>(props: PickersShortcutsProps<TValue>) {
const newValue = getValue({ isValid });

return {
key: item?.key || item.label,
...item,
label: item.label,
onClick: () => {
onChange(newValue, changeImportance, item);
Expand All @@ -89,7 +93,7 @@ function PickersShortcuts<TValue>(props: PickersShortcutsProps<TValue>) {
>
{resolvedItems.map((item) => {
return (
<ListItem key={item.label}>
<ListItem key={item.id ?? item.label}>
<Chip {...item} />
</ListItem>
);
Expand Down

0 comments on commit 820c4b9

Please sign in to comment.