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

[Bug]: Button click event change value in input form #1473

Open
pierre2202 opened this issue Oct 9, 2024 · 7 comments
Open

[Bug]: Button click event change value in input form #1473

pierre2202 opened this issue Oct 9, 2024 · 7 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@pierre2202
Copy link

pierre2202 commented Oct 9, 2024

What happened?

`  <.simple_form for={@form} id="login_form" action={~p"/users/log_in"} method="post">

<.input style="frame(width: 225) disabled(true)"  field={@form[:pin]}  value={@pin} type="SecureField" label="Pin"> </.input> 
<.simple_form/>
 <Button  phx-click="1" phx-value-v="1" >1 </Button>

Hello , when i click on the button in macos lvngo the value doesnt change all the time,
in ios lvngo the first time value dont change but after the value change with a gap.
The problem is only in a form.

if i write this code all is ok but that is not normal

def handle_event("1", %{"v" => v}, socket) do
    send(self(), "test")
    cond do
      v == "cancel" ->
        s = String.length(socket.assigns.pin)
        s = String.slice("elixir", 0, s-1)

        {:noreply,  socket |> assign(pin: s)}
      v == "reset" ->
        {:noreply,  socket |> assign(pin: "")}

        true ->
  {:noreply,  socket |> assign(pin: socket.assigns.pin <> v)}

      end

end

def handle_info("test", socket) do

  {:noreply, socket |>  push_patch(to: ~p"/users/log_in")}

end

Library Version

last

Xcode Version

last

Swift Version

last

On which device or simulator are you running into the problem?

iPhone, MacOS

Target Device Operating System Version

last

Relevant log output

No response

@pierre2202 pierre2202 added the bug Something isn't working label Oct 9, 2024
@bcardarella
Copy link
Collaborator

@pierre2202 we just published LVN Go for MacOS 0.3.1 that included the 0.3.1 release of the client that I think will solve this problem. Can you confirm your LVN Go version to see if this resolves your issue?

@pierre2202
Copy link
Author

pierre2202 commented Oct 9, 2024

i updated with the last version 0.3.1 all liveview native but the problem is always here, i did a mix deps ,compiled and relaunched the server

@bcardarella
Copy link
Collaborator

can you share an example app for us to quickly diagnose?

@pierre2202
Copy link
Author

pierre2202 commented Oct 9, 2024

of course link of the app

user_login_live.ex

@pierre2202
Copy link
Author

i tried a swift method ,that work better with lvngo ios but sometimes not . In macos that dont work.
front end :
<SecureField style={["frame(width: 225)","disabled(true)",~s[focused(attr("focus"))]]} focus={@focus} text={@pin} name="pin">Pin</SecureField>

back end

def handle_event("1", %{"v" => v}, socket) do
    socket =
      socket |> assign(focus: "false")

    send(self(), {"test", %{v: v}})


    {:noreply, socket}

end
def handle_info({"test", %{v: v}}, socket) do
  cond do
    v == "cancel" ->
      s = String.length(socket.assigns.pin)
      s = String.slice(socket.assigns.pin, 0, s-1)

    socket =  socket |> assign(pin: s)
    {:noreply, socket |> assign(focus: "true") }
    v == "reset" ->
      socket = socket |> assign(pin: "")
      {:noreply, socket |> assign(focus: "true") }

      true ->
socket =  socket |> assign(pin: socket.assigns.pin <> v)
{:noreply, socket |> assign(focus: "true") }

      end
end

@bcardarella
Copy link
Collaborator

@pierre2202 unfortunately Carson (our Swift dev) was dealing witth Hurricane Milton and lost power. I'm hoping he'll be back next week and I'll have him take a look at this.

I did take a look at the app you linked but it was very large. It would be helpful if you could isolate this issue in an example app that only has the relevant code. Thanks!

@pierre2202
Copy link
Author

no problem i did that, the exampleapp is uploaded with only the user_login_live.ex on http://localhost:4000/ when server is launched

@bcardarella bcardarella added this to the 0.5.0 milestone Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants