Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to control selected dates from parent component, and react to internal selections in parent components #68

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Fix bug with range pickers without pre-selected dates
  • Loading branch information
t-lock committed Aug 20, 2024
commit 0be4f7821b75199ab1923fbaede65a71771ca474
10 changes: 5 additions & 5 deletions src/components/DatePicker.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script>
import Popover from './Popover.svelte'
import { dayjs } from './lib/date-utils'
import { contextKey, setup } from './lib/context'
import { createEventDispatcher, setContext, getContext } from 'svelte'
import { createEventDispatcher, getContext, setContext } from 'svelte'
import { CalendarStyle } from '../calendar-style.js'
import { contextKey, setup } from './lib/context'
import { dayjs } from './lib/date-utils'
import { createViewContext } from './lib/view-context.js'
import Popover from './Popover.svelte'
import Toolbar from './Toolbar.svelte'
import View from './view/View.svelte'

@@ -122,7 +122,7 @@
* and updating with JS Date objects
*/
$: {
if (config.isRangePicker) {
if (config.isRangePicker && selected) {
if (selected[0] instanceof Date) {
selectedStartDate.set(dayjs(selected[0]))
}