Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/mui-material/src/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ describe('<Select />', () => {
await user.pointer({ keys: '[MouseLeft>]', target: trigger });

await act(async () => {
await sleep(450);
// Well past the 400ms selected-item window; a tight margin flakes on slow CI.
await sleep(700);
});

await user.pointer({
Expand All @@ -283,7 +284,8 @@ describe('<Select />', () => {
await user.pointer({ keys: '[MouseLeft>]', target: trigger });

await act(async () => {
await sleep(250);
// Well past the 200ms drag window; a tight margin flakes on slow CI.
await sleep(400);
});
await user.pointer({
keys: '[/MouseLeft]',
Expand Down Expand Up @@ -332,7 +334,8 @@ describe('<Select />', () => {
await user.pointer({ keys: '[MouseLeft>]', target: trigger });

await act(async () => {
await sleep(250);
// Well past the 200ms drag window; a tight margin flakes on slow CI.
await sleep(400);
});
await user.pointer({
keys: '[/MouseLeft]',
Expand Down
10 changes: 6 additions & 4 deletions packages/mui-material/src/Select/SelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,16 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {
selectionRef.current.allowUnselectedMouseUp = true;
});
} else {
// Both timers start from the mousedown. Chaining the selected timer inside the
// unselected callback would compound setTimeout jitter past the 400ms window.
// mousedown -> move to unselected item -> mouseup should not select within 200ms.
unselectedMouseUpTimer.start(UNSELECTED_MOUSE_UP_DELAY, () => {
selectionRef.current.allowUnselectedMouseUp = true;
});

// mousedown -> mouseup on selected item should not select within 400ms.
selectedMouseUpTimer.start(UNSELECTED_MOUSE_UP_DELAY, () => {
selectionRef.current.allowSelectedMouseUp = true;
});
// mousedown -> mouseup on selected item should not select within 400ms.
selectedMouseUpTimer.start(SELECTED_MOUSE_UP_DELAY, () => {
selectionRef.current.allowSelectedMouseUp = true;
});
}
};
Expand Down
Loading