hotwired / turbo-android

Android framework for making Turbo native apps
MIT License
407 stars 51 forks source link

data-turbo-action="replace" results in 2 network requests #291

Closed MichalSznajder closed 4 months ago

MichalSznajder commented 7 months ago

I am trying to implement search-as-you type for my app. I prepared HTML like this:

<turbo-frame id="search_result">
    ... results go here 
</turbo-frame>

<form method="get" 
      data-turbo-frame="search_result" 
      data-turbo-action="replace">
    <editbox + stimulus controller to submit form with keypress>
</form>

On desktop browser there is no problem: form is submitted and results are only updated in frame, search term stays in editbox and address bar is replaced on each keystroke.

On mobile form is submitted, server renders response and visit is proposed to app. This later changes into visit(action=ADVANCE) which results in another request to server and for some reason page is not updated.

Any idea if this is my mistake or a bug in turbo-android?

MichalSznajder commented 7 months ago

Maybe this is related to https://github.com/hotwired/turbo-android/blob/bf945e18aed3d5749c9efc6e228d98bc012878af/turbo/src/main/kotlin/dev/hotwire/turbo/session/TurboSession.kt#L452-L461

TurboVisitAction.REPLACE will be mutated here into ADVANCE.

jayohms commented 4 months ago

This is resolved with Turbo 8 morph refreshes + #292