mirror of
https://github.com/adoyle0/thaw.git
synced 2025-01-23 06:19:22 -05:00
fix: ParentRoute view reuse
This commit is contained in:
parent
482bfdb875
commit
51b04d911b
3 changed files with 66 additions and 60 deletions
|
@ -21,6 +21,7 @@ send_wrapper = "0.6"
|
||||||
console_error_panic_hook = "0.1.7"
|
console_error_panic_hook = "0.1.7"
|
||||||
console_log = "1"
|
console_log = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
js-sys = "0.3.70"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["csr"]
|
default = ["csr"]
|
||||||
|
|
110
demo/src/app.rs
110
demo/src/app.rs
|
@ -58,60 +58,62 @@ fn TheRouter() -> impl IntoView {
|
||||||
<Route path=path!("/development/components") view=DevelopmentComponentsMdPage/>
|
<Route path=path!("/development/components") view=DevelopmentComponentsMdPage/>
|
||||||
</ParentRoute>
|
</ParentRoute>
|
||||||
<ParentRoute path=path!("/components") view=ComponentsPage>
|
<ParentRoute path=path!("/components") view=ComponentsPage>
|
||||||
<Route path=path!("/accordion") view=AccordionMdPage/>
|
{view!{
|
||||||
<Route path=path!("/anchor") view=AnchorMdPage/>
|
<Route path=path!("/accordion") view=AccordionMdPage/>
|
||||||
<Route path=path!("/auto-complete") view=AutoCompleteMdPage/>
|
<Route path=path!("/anchor") view=AnchorMdPage/>
|
||||||
<Route path=path!("/avatar") view=AvatarMdPage/>
|
<Route path=path!("/auto-complete") view=AutoCompleteMdPage/>
|
||||||
<Route path=path!("/back-top") view=BackTopMdPage/>
|
<Route path=path!("/avatar") view=AvatarMdPage/>
|
||||||
<Route path=path!("/badge") view=BadgeMdPage/>
|
<Route path=path!("/back-top") view=BackTopMdPage/>
|
||||||
<Route path=path!("/breadcrumb") view=BreadcrumbMdPage/>
|
<Route path=path!("/badge") view=BadgeMdPage/>
|
||||||
<Route path=path!("/button") view=ButtonMdPage/>
|
<Route path=path!("/breadcrumb") view=BreadcrumbMdPage/>
|
||||||
<Route path=path!("/calendar") view=CalendarMdPage/>
|
<Route path=path!("/button") view=ButtonMdPage/>
|
||||||
<Route path=path!("/card") view=CardMdPage/>
|
<Route path=path!("/calendar") view=CalendarMdPage/>
|
||||||
<Route path=path!("/checkbox") view=CheckboxMdPage/>
|
<Route path=path!("/card") view=CardMdPage/>
|
||||||
<Route path=path!("/color-picker") view=ColorPickerMdPage/>
|
<Route path=path!("/checkbox") view=CheckboxMdPage/>
|
||||||
<Route path=path!("/combobox") view=ComboboxMdPage/>
|
<Route path=path!("/color-picker") view=ColorPickerMdPage/>
|
||||||
<Route path=path!("/config-provider") view=ConfigProviderMdPage/>
|
<Route path=path!("/combobox") view=ComboboxMdPage/>
|
||||||
</ParentRoute>
|
<Route path=path!("/config-provider") view=ConfigProviderMdPage/>
|
||||||
<ParentRoute path=path!("/components") view=ComponentsPage>
|
}.into_inner()}
|
||||||
<Route path=path!("/date-picker") view=DatePickerMdPage/>
|
{view!{
|
||||||
<Route path=path!("/dialog") view=DialogMdPage/>
|
<Route path=path!("/date-picker") view=DatePickerMdPage/>
|
||||||
<Route path=path!("/divider") view=DividerMdPage/>
|
<Route path=path!("/dialog") view=DialogMdPage/>
|
||||||
<Route path=path!("/drawer") view=DrawerMdPage/>
|
<Route path=path!("/divider") view=DividerMdPage/>
|
||||||
<Route path=path!("/field") view=FieldMdPage/>
|
<Route path=path!("/drawer") view=DrawerMdPage/>
|
||||||
<Route path=path!("/menu") view=MenuMdPage/>
|
<Route path=path!("/field") view=FieldMdPage/>
|
||||||
<Route path=path!("/grid") view=GridMdPage/>
|
<Route path=path!("/menu") view=MenuMdPage/>
|
||||||
<Route path=path!("/icon") view=IconMdPage/>
|
<Route path=path!("/grid") view=GridMdPage/>
|
||||||
<Route path=path!("/image") view=ImageMdPage/>
|
<Route path=path!("/icon") view=IconMdPage/>
|
||||||
<Route path=path!("/input") view=InputMdPage/>
|
<Route path=path!("/image") view=ImageMdPage/>
|
||||||
<Route path=path!("/layout") view=LayoutMdPage/>
|
<Route path=path!("/input") view=InputMdPage/>
|
||||||
<Route path=path!("/loading-bar") view=LoadingBarMdPage/>
|
<Route path=path!("/layout") view=LayoutMdPage/>
|
||||||
<Route path=path!("/message-bar") view=MessageBarMdPage/>
|
<Route path=path!("/loading-bar") view=LoadingBarMdPage/>
|
||||||
<Route path=path!("/nav") view=NavMdPage/>
|
<Route path=path!("/message-bar") view=MessageBarMdPage/>
|
||||||
<Route path=path!("/pagination") view=PaginationMdPage/>
|
<Route path=path!("/nav") view=NavMdPage/>
|
||||||
<Route path=path!("/popover") view=PopoverMdPage/>
|
<Route path=path!("/pagination") view=PaginationMdPage/>
|
||||||
</ParentRoute>
|
<Route path=path!("/popover") view=PopoverMdPage/>
|
||||||
<ParentRoute path=path!("/components") view=ComponentsPage>
|
}.into_inner()}
|
||||||
<Route path=path!("/progress-bar") view=ProgressBarMdPage/>
|
{view!{
|
||||||
<Route path=path!("/radio") view=RadioMdPage/>
|
<Route path=path!("/progress-bar") view=ProgressBarMdPage/>
|
||||||
<Route path=path!("/scrollbar") view=ScrollbarMdPage/>
|
<Route path=path!("/radio") view=RadioMdPage/>
|
||||||
<Route path=path!("/skeleton") view=SkeletonMdPage/>
|
<Route path=path!("/scrollbar") view=ScrollbarMdPage/>
|
||||||
<Route path=path!("/slider") view=SliderMdPage/>
|
<Route path=path!("/skeleton") view=SkeletonMdPage/>
|
||||||
<Route path=path!("/space") view=SpaceMdPage/>
|
<Route path=path!("/slider") view=SliderMdPage/>
|
||||||
<Route path=path!("/spin-button") view=SpinButtonMdPage/>
|
<Route path=path!("/space") view=SpaceMdPage/>
|
||||||
<Route path=path!("/spinner") view=SpinnerMdPage/>
|
<Route path=path!("/spin-button") view=SpinButtonMdPage/>
|
||||||
<Route path=path!("/switch") view=SwitchMdPage/>
|
<Route path=path!("/spinner") view=SpinnerMdPage/>
|
||||||
<Route path=path!("/tab-list") view=TabListMdPage/>
|
<Route path=path!("/switch") view=SwitchMdPage/>
|
||||||
<Route path=path!("/table") view=TableMdPage/>
|
<Route path=path!("/tab-list") view=TabListMdPage/>
|
||||||
<Route path=path!("/tag") view=TagMdPage/>
|
<Route path=path!("/table") view=TableMdPage/>
|
||||||
<Route path=path!("/text") view=TextMdPage/>
|
<Route path=path!("/tag") view=TagMdPage/>
|
||||||
<Route path=path!("/textarea") view=TextareaMdPage/>
|
<Route path=path!("/text") view=TextMdPage/>
|
||||||
<Route path=path!("/time-picker") view=TimePickerMdPage/>
|
<Route path=path!("/textarea") view=TextareaMdPage/>
|
||||||
<Route path=path!("/toast") view=ToastMdPage />
|
<Route path=path!("/time-picker") view=TimePickerMdPage/>
|
||||||
</ParentRoute>
|
<Route path=path!("/toast") view=ToastMdPage />
|
||||||
<ParentRoute path=path!("/components") view=ComponentsPage>
|
}.into_inner()}
|
||||||
<Route path=path!("/tooltip") view=TooltipMdPage />
|
{view!{
|
||||||
<Route path=path!("/upload") view=UploadMdPage/>
|
<Route path=path!("/tooltip") view=TooltipMdPage />
|
||||||
|
<Route path=path!("/upload") view=UploadMdPage/>
|
||||||
|
}.into_inner()}
|
||||||
</ParentRoute>
|
</ParentRoute>
|
||||||
</Routes>
|
</Routes>
|
||||||
</Router>
|
</Router>
|
||||||
|
|
|
@ -77,14 +77,17 @@ pub fn SiteHeader() -> impl IntoView {
|
||||||
#[cfg(any(feature = "csr", feature = "hydrate"))]
|
#[cfg(any(feature = "csr", feature = "hydrate"))]
|
||||||
{
|
{
|
||||||
use leptos::ev;
|
use leptos::ev;
|
||||||
let handle = window_event_listener(ev::keydown, move |event| {
|
let handle = window_event_listener(ev::keydown, move |e| {
|
||||||
let key = event.key();
|
if js_sys::Reflect::has(&e, &js_sys::wasm_bindgen::JsValue::from_str("key")).unwrap_or_default() {
|
||||||
if key == *"/" {
|
let key = e.key();
|
||||||
if let Some(auto_complete_ref) = auto_complete_ref.get_untracked() {
|
if key == *"/" {
|
||||||
event.prevent_default();
|
if let Some(auto_complete_ref) = auto_complete_ref.get_untracked() {
|
||||||
auto_complete_ref.focus();
|
e.prevent_default();
|
||||||
|
auto_complete_ref.focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
on_cleanup(move || handle.remove());
|
on_cleanup(move || handle.remove());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue