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
aria-selected="false"
class="ant-select-item ant-select-item-option year-item"
aria-selected="true"
class="ant-select-item ant-select-item-option year-item ant-select-item-option-selected"
title="2016"
>
<div

View File

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