Skip to content

Commit fca17ff

Browse files
authored
fix: needConfirm false should not trigger open in SinglePicker (#915)
* fix: needConfirm false should not trigger open in SinglePicker (#914) * chore: clean up * chore: update script
1 parent ec4f698 commit fca17ff

File tree

5 files changed

+27
-88
lines changed

5 files changed

+27
-88
lines changed

jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
module.exports = {
2-
setupFiles: ['./tests/setup.js'],
32
coveragePathIgnorePatterns: ['src/locale/', 'tests/'],
43
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"build": "dumi build",
3030
"compile": "father build && lessc assets/index.less assets/index.css",
3131
"gh-pages": "npm run build && father doc deploy",
32-
"prepublishOnly": "npm run compile && np --yolo --no-publish",
32+
"prepublishOnly": "npm run compile && np --yolo --no-publish --any-branch",
3333
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
3434
"lint:tsc": "tsc -p tsconfig.json --noEmit",
3535
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",

src/PickerInput/SinglePicker.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,6 @@ function Picker<DateType extends object = any>(
603603

604604
// Submit with complex picker
605605
if (!mergedOpen && complexPicker && !needConfirm && lastOp === 'panel') {
606-
triggerOpen(true);
607606
triggerConfirm();
608607
}
609608
}, [mergedOpen]);

tests/new-range.spec.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,32 @@ describe('NewPicker.Range', () => {
785785
expect(container.querySelectorAll('input')[0]).toHaveValue('1990-09-05');
786786
expect(container.querySelectorAll('input')[1]).toHaveValue('1990-09-05');
787787
});
788+
789+
it('not trigger open when !needConfirm', () => {
790+
const onChange = jest.fn();
791+
const onOpenChange = jest.fn();
792+
793+
const { container } = render(
794+
<DayPicker showTime onChange={onChange} onOpenChange={onOpenChange} needConfirm={false} />,
795+
);
796+
openPicker(container);
797+
798+
fireEvent.click(findCell(5));
799+
800+
act(() => {
801+
jest.runAllTimers();
802+
});
803+
expect(onOpenChange).toHaveBeenCalledWith(true);
804+
805+
// Window click to close
806+
fireEvent.mouseDown(document.body);
807+
act(() => {
808+
jest.runAllTimers();
809+
});
810+
811+
expect(onOpenChange).toHaveBeenCalledTimes(2);
812+
expect(onOpenChange).toHaveBeenCalledWith(false);
813+
});
788814
});
789815

790816
describe('open', () => {

tests/setup.js

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)