htmx icon indicating copy to clipboard operation
htmx copied to clipboard

path-deps sends requests even when mutating request fails

Open Alireza-Farahani opened this issue 2 years ago • 3 comments

Is it intended or is it a bug? If intended, is there a way I can turn it off?

I don't think code snippet be much help but here it is:

<div id="np-tag-list" class="d-flex flex-wrap gap-3 py-3 px-1" hx-get="/tags/" hx-ext="path-deps" hx-trigger="path-deps" hx-swap="outerHTML" path-deps="/tags/*"> 
      <div class="btn-group">        
        <button type="button" class="btn btn-secondary pe-none">
          Biology
        </button>
          <button type="button" class="btn btn-secondary" hx-delete="/tags/4/followership/">
            ×
          </button>
      </div>

      <div class="btn-group">
        <button type="button" class="btn btn-secondary pe-none">
          Needs Review
        </button>
          <button type="button" class="btn btn-secondary" hx-post="/tags/6/followership/">
            +
          </button>        
      </div>
</div>

buttons with + or x text send failing post/delete requests but path-deps reloads the outer div nonetheless.

Alireza-Farahani avatar Dec 07 '21 16:12 Alireza-Farahani

what does fail mean in this context?

1cg avatar Apr 07 '22 20:04 1cg

Http status code in range of [400, 599]

Alireza-Farahani avatar Apr 09 '22 06:04 Alireza-Farahani

Two approaches come to mind:

  1. Leverage status codes per @Alireza-Farahani , though perhaps allow developer to whitelist which codes should trigger the GET requests associated with a given configured mutation request (X-POST, X-DELETE, etc).
  2. Allow developer to pass a certain header to indicate mutation failure.

I'm not familiar with HTTP spec, so I don't know if I'm missing any important nuances.

paxperscientiam avatar Aug 21 '22 17:08 paxperscientiam