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

phx-throttle doesn't appear to work #1531

Open
bcardarella opened this issue Feb 13, 2025 · 0 comments
Open

phx-throttle doesn't appear to work #1531

bcardarella opened this issue Feb 13, 2025 · 0 comments

Comments

@bcardarella
Copy link
Collaborator

I have the following form:

        <.simple_form id="message-form" phx-change="validate" for={@form} phx-submit="send">
          <.input
            phx-throttle="1000"
            class={[
              "message-input",
              @form_disabled && "disabled"
            ]}
            type="TextField"
            field={@form[:message]}
            label="Message"
          />
          <:actions>
            <LiveButton
              class={[
                @form_disabled && "disabled"
              ]}
              type="submit"
            >
              <Image class="button-send" systemName="sailboat"/>
            </LiveButton>
          </:actions>
        </.simple_form>

the phx-throttle="1000" on the input should prevent the phx-change event from firing more than once per second.

The behavior is described here: https://hexdocs.pm/phoenix_live_view/bindings.html#rate-limiting-events-with-debounce-and-throttle

So fire immediately then ignore additional events until the timer in ms is expired.

It does appear that we have throttle behavior in the lib but maybe these aren't applying for form's in the way described above. This is supported on Web.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant