Skip to content

Form submit in non-LiveView page should be classified as :full_page #6

@pinetops

Description

@pinetops

Problem

A <button type="submit"> inside a plain HTML form (no phx-submit) is classified as :none by classify_interaction. When the form submit triggers a full page navigation to a LiveView page, wallabidi doesn't wait for the page load or LiveView connection.

Impact

After clicking "Continue to Teamology" (plain form submit → redirect to /school LiveView), the next interaction — click(Query.css("[id='#profile-menu-button']")) — fires before LiveSocket connects. The button's phx-click={JS.toggle(...)} binding isn't active yet, so the dropdown doesn't open.

Current workaround

teacher
|> assert_has(Query.css(".phx-connected"))  # wait for LiveSocket
|> click(Query.css("[id='#profile-menu-button']"))

Suggested fix

In check_phx_binding / check_phx_binding_xpath, if the element is a submit button inside a <form> (even without phx-submit), classify as :full_page:

if (type === 'click') {
  // ... existing phx-click checks ...
  
  // Submit button inside any form → full page navigation
  if (el.type === 'submit' || el.tagName === 'BUTTON') {
    var form = el.closest('form');
    if (form && form.getAttribute('phx-submit')) return 'patch';
    if (form) return 'full_page';  // non-LiveView form submit
  }
  
  // ... existing anchor checks ...
}

This ensures await_page_load + await_liveview_connected run after the form submit, so the next page's LiveSocket is connected before subsequent interactions.

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