Skip to content

Commit

Permalink
[pickers] Do not close the picker when doing keyboard editing (mui#16402
Browse files Browse the repository at this point in the history
)
  • Loading branch information
flaviendelangle authored Jan 31, 2025
1 parent 0736d31 commit 099602f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function useFieldInternalPropsWithDefaults<TManager extends PickerAnyMana
(newValue, ctx) => {
return setValue?.(newValue, {
validationError: ctx.validationError,
shouldClose: false,
});
},
[setValue],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const usePickerValue = <
skipPublicationIfPristine = false,
validationError,
shortcut,
shouldClose = changeImportance === 'accept',
} = options ?? {};

let shouldPublish: boolean;
Expand Down Expand Up @@ -193,7 +194,7 @@ export const usePickerValue = <
onAccept(newValue, getContext());
}

if (changeImportance === 'accept') {
if (shouldClose) {
setOpen(false);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,9 @@ export interface SetValueActionOptions<TError = string | null> {
* @default false
*/
skipPublicationIfPristine?: boolean;
/**
* Whether the picker should close.
* @default changeImportance === "accept"
*/
shouldClose?: boolean;
}

0 comments on commit 099602f

Please # to comment.