From 4779eb2d24abf2cef8c6cce713f5dd1e1a761a03 Mon Sep 17 00:00:00 2001 From: luoxiaozero <48741584+luoxiaozero@users.noreply.github.com> Date: Sun, 25 Feb 2024 01:15:18 +0800 Subject: [PATCH] fix: Modal nightly (#119) --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ demo_markdown/docs/input/mod.md | 12 ++++++++++-- examples/ssr_axum/Cargo.toml | 1 + thaw/src/modal/mod.rs | 4 ++-- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f764ed..a3b101d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,3 +75,27 @@ jobs: run: | cd ./examples/ssr_axum cargo leptos build --release + nightly-cargo-leptos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + target: wasm32-unknown-unknown + override: true + - name: Install Trunk + uses: jetli/trunk-action@v0.4.0 + with: + version: "latest" + - name: Install Cargo BInstall + uses: cargo-bins/cargo-binstall@main + - name: Install Cargo Leptos + run: cargo binstall cargo-leptos -y + - name: Build + run: | + cd ./examples/ssr_axum + cargo leptos build --release --features nightly diff --git a/demo_markdown/docs/input/mod.md b/demo_markdown/docs/input/mod.md index 20ba362..285ecbf 100644 --- a/demo_markdown/docs/input/mod.md +++ b/demo_markdown/docs/input/mod.md @@ -44,13 +44,21 @@ view! { let value = create_rw_signal(String::from("o")); let input_ref = create_component_ref::(); +let focus = Callback::new(move |_| { + input_ref.get_untracked().unwrap().focus() +}); + +let blur = Callback::new(move |_| { + input_ref.get_untracked().unwrap().blur() +}); + view! { - - diff --git a/examples/ssr_axum/Cargo.toml b/examples/ssr_axum/Cargo.toml index 2616981..655ce95 100644 --- a/examples/ssr_axum/Cargo.toml +++ b/examples/ssr_axum/Cargo.toml @@ -45,6 +45,7 @@ ssr = [ "dep:tracing", "demo/ssr", ] +nightly = ["demo/nightly"] # Defines a size-optimized profile for the WASM bundle in release mode [profile.wasm-release] diff --git a/thaw/src/modal/mod.rs b/thaw/src/modal/mod.rs index a78a75b..0c0ed61 100644 --- a/thaw/src/modal/mod.rs +++ b/thaw/src/modal/mod.rs @@ -33,7 +33,7 @@ pub fn Modal( let modal_ref = NodeRef::::new(); let click_position = use_click_position(); - let on_enter = move |_| { + let on_enter = Callback::new(move |_| { let Some(position) = click_position.get_untracked() else { return; }; @@ -51,7 +51,7 @@ pub fn Modal( let y = -(modal_el.offset_top() - position.1 - scroll_top); let _ = modal_el.attr("style", format!("transform-origin: {}px {}px", x, y)); - }; + }); view! {