diff --git a/playground/app.tsx b/playground/app.tsx
index eb83d8c..c26d28d 100644
--- a/playground/app.tsx
+++ b/playground/app.tsx
@@ -19,7 +19,7 @@ export default () => {
}}
onSelect={onSelect}
localization="zh-CN"
- closable
+ onClose={() => alert('close')}
/>
)
diff --git a/src/components/SingleDatePicker.tsx b/src/components/SingleDatePicker.tsx
index 2486fbd..8a11b0e 100644
--- a/src/components/SingleDatePicker.tsx
+++ b/src/components/SingleDatePicker.tsx
@@ -34,15 +34,11 @@ interface Props {
/**
* User requires to close the panel without select a specific date. Note that the close button is not
- * visible, but can be read by screen reader.
+ * visible, but can be read by screen reader. The close button for the screen reader is only available
+ * when this prop is not `undefined`.
+ * @default undefined
*/
onClose?: () => void
-
- /**
- * Show a close button to the users with screen reader.
- * @default false
- */
- closable?: boolean
}
/**
@@ -52,7 +48,7 @@ interface Props {
*
* @param {Props} props
*/
-export default ({ value, onSelect, localization, onClose, closable = false }: Props) => {
+export default ({ value, onSelect, localization, onClose }: Props) => {
const [currentMonth, setCurrentMonth] = useState(new Date().getMonth())
const [currentYear, setCurrentYear] = useState(new Date().getFullYear())
const [selectedDate, setSelectedDate] = useState(new Date())
@@ -127,7 +123,7 @@ export default ({ value, onSelect, localization, onClose, closable = false }: Pr
{new Date(currentYear, index).toLocaleString(localization || navigator.language, { month: 'long' })}
)}
- { closable && }
+ { !!onClose && }
)
else return (
@@ -154,7 +150,7 @@ export default ({ value, onSelect, localization, onClose, closable = false }: Pr
{date.toDateString() === new Date().toDateString() && }
)}
- { closable && }
+ { !!onClose && }
)
}
\ No newline at end of file