docs: fix customize calendar example (#36356)

* docs: fix customize calendar example

* test: changed calendar snapshot

Co-authored-by: lico <lico@licoui-MacBookPro.local>
This commit is contained in:
hsk-kr 2022-07-07 00:29:57 +09:00 committed by GitHub
parent 2e04982882
commit e262ae8133
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 14 deletions

View File

@ -3481,8 +3481,8 @@ exports[`renders ./components/calendar/demo/customize-header.md extend context c
/> />
</div> </div>
<div <div
aria-selected="false" aria-selected="true"
class="ant-select-item ant-select-item-option year-item" class="ant-select-item ant-select-item-option year-item ant-select-item-option-selected"
title="2016" title="2016"
> >
<div <div

View File

@ -41,16 +41,16 @@ const App: React.FC = () => {
months.push(localeData.monthsShort(current)); months.push(localeData.monthsShort(current));
} }
for (let index = start; index < end; index++) { for (let i = start; i < end; i++) {
monthOptions.push( monthOptions.push(
<Select.Option className="month-item" key={`${index}`}> <Select.Option key={i} value={i} className="month-item">
{months[index]} {months[i]}
</Select.Option>, </Select.Option>,
); );
} }
const month = value.month();
const year = value.year(); const year = value.year();
const month = value.month();
const options = []; const options = [];
for (let i = year - 10; i < year + 10; i += 1) { for (let i = year - 10; i < year + 10; i += 1) {
options.push( options.push(
@ -78,11 +78,11 @@ const App: React.FC = () => {
size="small" size="small"
dropdownMatchSelectWidth={false} dropdownMatchSelectWidth={false}
className="my-year-select" className="my-year-select"
value={year}
onChange={newYear => { onChange={newYear => {
const now = value.clone().year(Number(newYear)); const now = value.clone().year(newYear);
onChange(now); onChange(now);
}} }}
value={String(year)}
> >
{options} {options}
</Select> </Select>
@ -91,11 +91,10 @@ const App: React.FC = () => {
<Select <Select
size="small" size="small"
dropdownMatchSelectWidth={false} dropdownMatchSelectWidth={false}
value={String(month)} value={month}
onChange={selectedMonth => { onChange={newMonth => {
const newValue = value.clone(); const now = value.clone().month(newMonth);
newValue.month(parseInt(selectedMonth, 10)); onChange(now);
onChange(newValue);
}} }}
> >
{monthOptions} {monthOptions}