admin管理员组文章数量:1334805
my react-datepicker
cannot scroll months for some reason. Otherwise works perfectly fine, can select any date, its just arrow keys near month name (highligted on screenshot) don't do anything. If I remove the readonly
attribute I also can type in any date in predetirmened format but still the calendar is unscrollable?
Datepicker defenition:
<Grid item xs={6}>
<Controller
name={"periodFrom-" + input.index}
control={input.form}
render={({field: {onChange, value}, fieldState: {error}}) => (
<div style={{marginTop: "10px"}}>
<InputLabel>start date </InputLabel>
<DatePicker dateFormat="dd/MM/yyyy"
customInput={<TextField variant="outlined" fullWidth
error={!!error}
inputProps={{readOnly: true}}
helperText={error ? error.message : null}/>}
selected={value} onChange={onChange}/>
</div>
)}
/>
</Grid>
React version is latest ("^18.3.1")
Datepicker version is "^4.10.0" (not sure what it should be)
my react-datepicker
cannot scroll months for some reason. Otherwise works perfectly fine, can select any date, its just arrow keys near month name (highligted on screenshot) don't do anything. If I remove the readonly
attribute I also can type in any date in predetirmened format but still the calendar is unscrollable?
Datepicker defenition:
<Grid item xs={6}>
<Controller
name={"periodFrom-" + input.index}
control={input.form}
render={({field: {onChange, value}, fieldState: {error}}) => (
<div style={{marginTop: "10px"}}>
<InputLabel>start date </InputLabel>
<DatePicker dateFormat="dd/MM/yyyy"
customInput={<TextField variant="outlined" fullWidth
error={!!error}
inputProps={{readOnly: true}}
helperText={error ? error.message : null}/>}
selected={value} onChange={onChange}/>
</div>
)}
/>
</Grid>
React version is latest ("^18.3.1")
Datepicker version is "^4.10.0" (not sure what it should be)
Share Improve this question asked Nov 20, 2024 at 4:19 EcmaScriptIsMyNativeLanguageEcmaScriptIsMyNativeLanguage 132 bronze badges1 Answer
Reset to default 0Remove the readonly Attribute: If you want the month/year arrows to work (i.e., scrolling to previous/next months), you should remove the readonly attribute. The issue seems to be that the calendar navigation might be trying to use the input as an interactive part of the calendar, and readonly prevents it from doing so.
<Grid item xs={6}>
<Controller
name={"periodFrom-" + input.index}
control={input.form}
render={({field: {onChange, value}, fieldState: {error}}) => (
<div style={{marginTop: "10px"}}>
<InputLabel>start date</InputLabel>
<DatePicker
dateFormat="dd/MM/yyyy"
customInput={
<TextField
variant="outlined"
fullWidth
error={!!error}
inputProps={{}} // Remove readonly here
helperText={error ? error.message : null}
/>
}
selected={value}
onChange={onChange}
/>
</div>
)}
/>
</Grid>
本文标签: reactjsWhy can39t reactdatepicker scroll monthsStack Overflow
版权声明:本文标题:reactjs - Why can't react-datepicker scroll months? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742382410a2464357.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论