Skip to content

phx-throttle doesn't appear to work #1531

@bcardarella

Description

@bcardarella

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions