-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: calendar picker view scroll #6521
Open
Yueyanc
wants to merge
4
commits into
ant-design:master
Choose a base branch
from
Yueyanc:feat/calendar-picker-view-scroll
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,223
−4
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,100 changes: 550 additions & 550 deletions
1,100
src/components/calendar-picker-view/tests/__snapshots__/calendar-picker-view.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, { forwardRef, useRef } from 'react' | ||
import React, { forwardRef, useEffect, useRef } from 'react' | ||
import { withNativeProps } from '../../utils/native-props' | ||
import classNames from 'classnames' | ||
import Button from '../button' | ||
|
@@ -73,7 +73,12 @@ export const CalendarPicker = forwardRef< | |
getContainer, | ||
...calendarViewProps | ||
} = props | ||
|
||
useEffect(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useEffect(() => {
setImmediate(() => {
const dateRange = calendarRef.current?.getDateRange() ?? null
if (dateRange && dateRange[0]) {
calendarRef.current?.scrollTo(dateRange[0])
}
})
}, [visible]) 加setImmediate, 当 visible 为 true 时,calendarRef.current不能立刻取到 |
||
const dateRange = calendarRef.current?.getDateRange() ?? null | ||
if (dateRange && dateRange[0]) { | ||
calendarRef.current?.scrollTo(dateRange[0]) | ||
} | ||
}, [visible]) | ||
const footer = ( | ||
<div className={`${classPrefix}-footer`}> | ||
<Divider /> | ||
|
7,276 changes: 3,638 additions & 3,638 deletions
7,276
src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
Unchanged files with check annotations Beta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Till Now | ||
if (tillNow) { | ||
ret[0].push({ | ||
label: renderLabel('now', null!), | ||
value: TILL_NOW, | ||
}) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('numbers that start with 0 should be work', () => { | ||
const ref = createRef<InputRef>() | ||
render(<Input type='number' ref={ref} />) | ||
const input = document.querySelector('input')! | ||
fireEvent.change(input, { | ||
target: { value: '012' }, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
).toEqual('Bamboo') | ||
// Not close | ||
fireEvent.touchMove(document.querySelector('.adm-popover-inner-content')!) | ||
expect(document.querySelector('.adm-popover-hidden')).toBeFalsy() | ||
// Close |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fireEvent.click(plusButton) | ||
expect(onChange).toHaveBeenCalledWith('0.000000000000003') | ||
expect(container.querySelector('input')!.value).toEqual('0.000000000000003') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const maxRows = 5 | ||
const { getByRole } = render(<TextArea autoSize={{ minRows, maxRows }} />) | ||
const textarea = getByRole('textbox') | ||
const hiddenTextarea = document.querySelector( | ||
`.${classPrefix}-element-hidden` | ||
)! | ||
// mock | ||
test('set rows should be work', () => { | ||
const { getByRole } = render(<TextArea rows={1} autoSize />) | ||
const hiddenTextarea = document.querySelector( | ||
`.${classPrefix}-element-hidden` | ||
)! | ||
const textarea = getByRole('textbox') |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要加到 className 里,可以加个
data-date
。