Introducing CrudHunt:Open-source Full-stack CRUDs for Next.js by KeenThemes
Browse CrudHunt

Metronic 9 - datepicker not closing after selecting the date


I have copied the code from Metronic 9 for datepicker, particularly on this section

<Popover>
<PopoverTrigger asChild>
<button
id="date"
className={cn(
'input data-[state=open]:border-primary',
!date && 'text-muted-foreground'
)}
>
<KeenIcon icon="calendar" className="-ms-0.5" />
{date ? format(date, 'LLL dd, y') : <span>Pick a date</span>}
</button>
</PopoverTrigger>
<PopoverContent className="w-auto p-0" align="start">
<Calendar
initialFocus
mode="single" // Single date selection
defaultMonth={date}
selected={date}
onSelect={setDate}
// numberOfMonths={2}
/>
</PopoverContent>
</Popover>


After selecting the date, the calendar remains open and does not close. The intended behaviour is for the calendar to close after a date has been selected. To close the calendar, the user would need to click outside the calendar again.

How can I configure it to achieve this effect?


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)


Hi,

The popover component is quite flexible and you can apply your own logic to make it auto-closable after date range selection. To enable reset/apply buttons for the daterangepicker please change "/vite/src/pages/dashboards/demo1/light-sidebar/Demo1LightSidebarPage.tsx" and update with https://gist.github.com/keen333/a0dee16f81f6d52e2396dac31e4bf275


Regards,
Sean



That works, thanks a lot!



All the best happy


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(