https://htmx.org logo
Join Discord
Powered by
# htmx-general
  • m

    magnificent-boots-1658

    01/05/2023, 4:43 PM
    @mysterious-toddler-20573 you are, perhaps, the absolute tip-top of OSS maintainers. This community continues to be useful, friendly, and productive.
  • m

    magnificent-boots-1658

    01/05/2023, 4:43 PM
    It's no small feat!
  • h

    hundreds-cartoon-20446

    01/05/2023, 7:15 PM
    @limited-potato-46306 Interesting, thanks for reporting. I think the solution would be to additionally take a snapshot on
    htmx:load
    , but I’ll try out a few things and see if I can get it working properly with Hx-Location.
  • h

    hundreds-camera-24900

    01/05/2023, 7:21 PM
    My insight is that I did it in the simplest possible way and for a specific case (redirecting after logging in) and it's very very likely there's some wonkiness. If you put together a repo I'd be happy to try and make a fix this weekend
  • l

    limited-potato-46306

    01/05/2023, 7:33 PM
    @hundreds-cartoon-20446 @hundreds-camera-24900 In the HTMX source, hx-location is handled differently than other headers, and I think it is potentially on opportunity for a PR. I have a local copy of HTMX where I have changed things and it works (I think it doesnt break anything but havent run tests), so I may open a PR or if not I will post the diffs here shortly
  • h

    hundreds-cartoon-20446

    01/05/2023, 7:40 PM
    Ok great thank you, I’ll take a look when you submit it.
  • h

    hundreds-camera-24900

    01/05/2023, 7:40 PM
    lmk if I can help, or if it makes sense to make hx-location more consistent with other headers
  • h

    hundreds-camera-24900

    01/05/2023, 7:41 PM
    what's the usecase here out of curiosity? I don't intuitively get why you'd preserve page state on a redireciton
  • h

    hundreds-cartoon-20446

    01/05/2023, 7:42 PM
    @hundreds-camera-24900 preserving the dom state of certain elements across swaps so that Js can reinitialise it in a predictable way.
  • h

    hundreds-camera-24900

    01/05/2023, 7:43 PM
    like with alpine templates?
  • h

    hundreds-cartoon-20446

    01/05/2023, 7:43 PM
    Yes
  • h

    hundreds-camera-24900

    01/05/2023, 7:43 PM
    I've been bit by that for sure
  • h

    hundreds-cartoon-20446

    01/05/2023, 7:44 PM
    Right, it’s a pain because the history snapshot captures the rendered state after js has manipulated the Dom
  • h

    hundreds-cartoon-20446

    01/05/2023, 7:44 PM
    But sometimes that’s what you want, other times not
  • h

    hundreds-camera-24900

    01/05/2023, 7:44 PM
    yup... https://github.com/alpinejs/alpine/discussions/2924
  • l

    limited-potato-46306

    01/05/2023, 7:46 PM
    I've been transitioning a spa from Vue to htmx + alpine and the hx-history-preserve extension has made it pretty easy so far. Without it, I had all kinds of problems with navigation
  • h

    hundreds-camera-24900

    01/05/2023, 7:47 PM
    and the issue w/ hx-location is that since it's calling beforeHistorySave for the redirect, so the order is historySave -> swap -> history save
  • h

    hundreds-camera-24900

    01/05/2023, 7:47 PM
    and it's merging the original page load with the first historySave part of the redirect?
  • h

    hundreds-cartoon-20446

    01/05/2023, 7:48 PM
    Yes that’s it
  • h

    hundreds-camera-24900

    01/05/2023, 7:48 PM
    yeah that just seems wrong... it shouldn't save history for a redirect right?
  • h

    hundreds-cartoon-20446

    01/05/2023, 7:48 PM
    No not necessarily
  • h

    hundreds-cartoon-20446

    01/05/2023, 7:49 PM
    The logic is subtle I seem to remember
  • h

    hundreds-camera-24900

    01/05/2023, 7:49 PM
    when would you want someone navigating to the redirect state?
  • h

    hundreds-cartoon-20446

    01/05/2023, 7:50 PM
    The history state is saved when leaving the current page.
  • h

    hundreds-camera-24900

    01/05/2023, 7:51 PM
    right, but wouldn't the right thing to do be to drop the first historySave? so you just have a single beforeSwap and beforeHistorySave called on the redirect?
  • h

    hundreds-cartoon-20446

    01/05/2023, 7:53 PM
    I’d need to check when the browser history entry is created with pushState(), since that is when a history snapshot is required for back/forward navigation..
  • h

    hundreds-cartoon-20446

    01/05/2023, 7:54 PM
    Not at my desk right now but happy to dig into the problem tomorrow.
  • h

    hundreds-camera-24900

    01/05/2023, 7:55 PM
    lmk if you want a second pair of eyes - I'm planning on poking at hx-location this weekend anyway (https://github.com/bigskysoftware/htmx/issues/1129)
  • m

    mysterious-toddler-20573

    01/05/2023, 8:01 PM
    @hundreds-cartoon-20446 at some point we should have another chat about history
  • h

    hundreds-cartoon-20446

    01/05/2023, 8:02 PM
    Cool cool I’d better find that whisky bottle.
1...970971972...1146Latest