|
@@ -61,6 +61,16 @@ export default function DateTimePicker({
|
|
|
// Bumped on clear: persian-calendar-suite reads `value` only on mount, so
|
|
// Bumped on clear: persian-calendar-suite reads `value` only on mount, so
|
|
|
// remounting via key is the only way to reflect an externally cleared value.
|
|
// remounting via key is the only way to reflect an externally cleared value.
|
|
|
const [clearNonce, setClearNonce] = useState(0);
|
|
const [clearNonce, setClearNonce] = useState(0);
|
|
|
|
|
+ // Mounted without a value, persian-calendar-suite seeds today and emits it —
|
|
|
|
|
+ // which would instantly undo a clear. Armed across every (re)mount.
|
|
|
|
|
+ const suppressMountEmit = useRef(true);
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ suppressMountEmit.current = false;
|
|
|
|
|
+ return () => {
|
|
|
|
|
+ suppressMountEmit.current = true;
|
|
|
|
|
+ };
|
|
|
|
|
+ }, [clearNonce]);
|
|
|
|
|
|
|
|
const persianTheme = useMemo(() => {
|
|
const persianTheme = useMemo(() => {
|
|
|
if (isUltra) return ULTRA_DARK_THEME;
|
|
if (isUltra) return ULTRA_DARK_THEME;
|
|
@@ -80,11 +90,12 @@ export default function DateTimePicker({
|
|
|
|
|
|
|
|
if (datepicker === 'jalalian') {
|
|
if (datepicker === 'jalalian') {
|
|
|
return (
|
|
return (
|
|
|
- <div ref={jalaliRef} className={`jdp-wrap${isDark ? ' jdp-dark' : ''}${isUltra ? ' jdp-ultra' : ''}${disabled ? ' jdp-disabled' : ''}`}>
|
|
|
|
|
|
|
+ <div ref={jalaliRef} className={`jdp-wrap${isDark ? ' jdp-dark' : ''}${isUltra ? ' jdp-ultra' : ''}${disabled ? ' jdp-disabled' : ''}${value ? '' : ' jdp-empty'}`}>
|
|
|
<PersianDateTimePicker
|
|
<PersianDateTimePicker
|
|
|
key={clearNonce}
|
|
key={clearNonce}
|
|
|
value={value ? value.valueOf() : null}
|
|
value={value ? value.valueOf() : null}
|
|
|
onChange={(next: number | string | null) => {
|
|
onChange={(next: number | string | null) => {
|
|
|
|
|
+ if (suppressMountEmit.current) return;
|
|
|
if (next == null || next === '') {
|
|
if (next == null || next === '') {
|
|
|
onChange(null);
|
|
onChange(null);
|
|
|
return;
|
|
return;
|