Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b6b7d65

Browse files
committedAug 20, 2024
Fix event forwarding
1 parent b2a2f2e commit b6b7d65

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed
 

‎src/App.svelte

+5-4
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@
5959
<div class="row">
6060
<aside>
6161
<div class="menu-box">
62-
<h4>Navigation</h4>
62+
<h4>Navigation</h4>
6363
<nav class="side-nav">
6464
<ul>
6565
<li><a href="/">Home</a></li>
6666
<li><a href="/date-picker">Date Picker</a></li>
6767
<li><a href="/range-picker">Range Picker</a></li>
68-
</ul>
68+
</ul>
6969
</nav>
7070
</div>
7171
</aside>
@@ -273,6 +273,7 @@
273273
range={true}
274274
time={true}
275275
on:range-selected={e => {
276+
console.log(e)
276277
firedEvents = [
277278
...firedEvents,
278279
`Picked range ${e.detail.from} to ${e.detail.to}`
@@ -314,7 +315,7 @@
314315
<div class="container">
315316
<div class="row">
316317
<div class="col-lg-12 center">
317-
318+
318319
</div>
319320
</div>
320321
</div>
@@ -446,4 +447,4 @@
446447
background-position: 100%;
447448
}
448449
}
449-
</style>
450+
</style>

‎src/components/DatePicker.svelte

+29-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { onMount } from 'svelte'
2+
import { createEventDispatcher, onMount } from 'svelte'
33
import DatePickerInner from './DatePickerInner.svelte'
44
import { setLoadingCursor } from './lib/context'
55
@@ -9,14 +9,40 @@
99
await setLoadingCursor()
1010
ready = true
1111
})
12+
13+
/**
14+
* ! WARNING
15+
*
16+
* The only events forwarded here are the ones we are currently using in
17+
* Real Rev...
18+
*
19+
* Forwarding both Date and Date Range events bricked our build.
20+
*/
21+
const dispatch = createEventDispatcher()
22+
function forwardEvent (event) {
23+
console.log('Forwarding event:', event.type)
24+
dispatch(event.type, event.detail)
25+
}
1226
</script>
1327

1428
{#if ready}
1529
{#if $$slots.default}
16-
<DatePickerInner {...$$props} on:*>
30+
<DatePickerInner {...$$restProps}
31+
on:range-selected={forwardEvent}
32+
on:open={forwardEvent}
33+
on:close={forwardEvent}
34+
on:updateStart={forwardEvent}
35+
on:updateEnd={forwardEvent}
36+
>
1737
<slot />
1838
</DatePickerInner>
1939
{:else}
20-
<DatePickerInner {...$$props} on:* />
40+
<DatePickerInner {...$$restProps}
41+
on:range-selected={forwardEvent}
42+
on:open={forwardEvent}
43+
on:close={forwardEvent}
44+
on:updateStart={forwardEvent}
45+
on:updateEnd={forwardEvent}
46+
/>
2147
{/if}
2248
{/if}

0 commit comments

Comments
 (0)