Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

271
Vistas
Calendar popup needed to be closed after selecting the date

The calendar popup is not getting closed after selecting the date and it's wrapped in a label tag with an image and the calendar component. if I'm removing the label tag image tag is not activating the calendar popup.

`<label style={{width:"100%"}}>
  <DatePicker
    dateFormat="dd/MM/yyyy"
    placeholderText="Select Date"
    onChange={onChange}
    minDate={props.minDate ? props.minDate : null}
    maxDate={props.maxDate ? props.maxDate : null}
    className={props.className}
    style={{ width: '100%', marginTop:"-10px" }}
    selected={props.value && props.value !== "" ? new Date(props.value) : null}
    showDisabledMonthNavigation
  />
  <img
    src="./images/calendar.png"
    className="custom-input-icon img-fluid"
    alt="c"
    style={{ top: '25px' }}
  />
</label>`

so I tried calling the component using onClick event but it's not really working. i don't know how to do it. any help would be much appreciated.

   <>
   <DatePicker
dateFormat="dd/MM/yyyy"
placeholderText="Select Date"
onChange={onChange}
minDate={props.minDate ? props.minDate : null}
maxDate={props.maxDate ? props.maxDate : null}
className={props.className}
style={{ width: '100%', marginTop:"-10px" }}
selected={props.value && props.value !== "" ? new Date(props.value) : null}
showDisabledMonthNavigation

/>

  <img onClick={handleclick}
    src="./images/calendar.png"
    className="custom-input-icon img-fluid"
    alt="c"
    style={{ top: '25px' }}
  />
</>

handling click???

const handleclick = () => {console.log('ello');
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you need to wrap it like this but if i press the preselected date (current date) it won't close the popup so i need to click away to close it

import { DatePicker, LocalizationProvider } from '@mui/lab'
import roLocale from 'date-fns/locale/ro';
import DateAdapter from '@mui/lab/AdapterDateFns';
import { TextField } from '@mui/material';

const [error, setError] = useState(false)
const [value, setValue] = useState<Date | null>(null)

const handleChange = (newValue: Date | null) => {
    setValue(newValue)
}

{/* const handleValidation = () => {
    if (error) {
      alert(error)
    }
} */}

<LocalizationProvider dateAdapter={DateAdapter} locale={roLocale}>
        <DatePicker inputFormat="dd/MM/yyyy"
            label={label}
            openTo="year"
            value={value}
            // onError={err => setError(err ? true : false)}
            onChange={(newValue: Date | null) => handleChange(newValue)}
            maxDate={MIN_DATE}
            minDate={MAX_DATE}
            renderInput={(params) => <TextField variant="standard"
                // onBlur={handleValidation}
                fullWidth
                required={true}
                color="secondary"
                {...params} />} />
</LocalizationProvider>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda