Skip to content

Commit 00c906a

Browse files
committed
[fix] showTarget and settle parameters of @HxReswap are mapped to wrong HtmxReswap fields during conversion
1 parent d22df1a commit 00c906a

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

htmx-spring-boot/src/main/java/io/github/wimdeblauwe/htmx/spring/boot/mvc/HtmxHandlerMethodHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private String convertToReswap(HxReswap annotation) {
165165
reswap.swap(Duration.ofMillis(annotation.swap()));
166166
}
167167
if (annotation.settle() != -1) {
168-
reswap.swap(Duration.ofMillis(annotation.settle()));
168+
reswap.settle(Duration.ofMillis(annotation.settle()));
169169
}
170170
if (annotation.transition()) {
171171
reswap.transition();
@@ -176,7 +176,7 @@ private String convertToReswap(HxReswap annotation) {
176176
if (annotation.show() != HxReswap.Position.UNDEFINED) {
177177
reswap.show(convertToPosition(annotation.show()));
178178
if (!annotation.showTarget().isEmpty()) {
179-
reswap.scrollTarget(annotation.showTarget());
179+
reswap.showTarget(annotation.showTarget());
180180
}
181181
}
182182
if (annotation.scroll() != HxReswap.Position.UNDEFINED) {

htmx-spring-boot/src/test/java/io/github/wimdeblauwe/htmx/spring/boot/mvc/HtmxHandlerInterceptorTest.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public void testHxReplaceUrlShouldPrependContextPath() throws Exception {
171171
public void testHxReswap() throws Exception {
172172
mockMvc.perform(get("/hx-reswap"))
173173
.andExpect(status().isOk())
174-
.andExpect(header().string("HX-Reswap", "innerHTML swap:300ms"));
174+
.andExpect(header().string("HX-Reswap", "innerHTML transition:true focus-scroll:true swap:0ms settle:500ms scroll:#scrollTarget:top show:#showTarget:bottom"));
175175
}
176176

177177
@Test
@@ -206,7 +206,7 @@ public String methodWithHxTrigger() {
206206
}
207207

208208
@GetMapping("/with-trigger-multiple-events")
209-
@HxTrigger({ "event1", "event2" })
209+
@HxTrigger({"event1", "event2"})
210210
@ResponseBody
211211
public String methodWithHxTriggerAndMultipleEvents() {
212212
return "";
@@ -220,7 +220,7 @@ public String methodWithHxTriggerAfterSettle() {
220220
}
221221

222222
@GetMapping("/with-trigger-after-settle-multiple-events")
223-
@HxTriggerAfterSettle({ "event1", "event2" })
223+
@HxTriggerAfterSettle({"event1", "event2"})
224224
@ResponseBody
225225
public String methodWithHxTriggerAfterSettleAndMultipleEvents() {
226226
return "";
@@ -234,16 +234,16 @@ public String methodWithHxTriggerAfterSwap() {
234234
}
235235

236236
@GetMapping("/with-trigger-after-swap-multiple-events")
237-
@HxTriggerAfterSwap({ "event1", "event2" })
237+
@HxTriggerAfterSwap({"event1", "event2"})
238238
@ResponseBody
239239
public String methodWithHxTriggerAfterSwapAndMultipleEvents() {
240240
return "";
241241
}
242242

243243
@GetMapping("/with-triggers")
244-
@HxTrigger({ "event1", "event2" })
245-
@HxTriggerAfterSettle({ "event1", "event2" })
246-
@HxTriggerAfterSwap({ "event1", "event2" })
244+
@HxTrigger({"event1", "event2"})
245+
@HxTriggerAfterSettle({"event1", "event2"})
246+
@HxTriggerAfterSwap({"event1", "event2"})
247247
@ResponseBody
248248
public String methodWithHxTriggers() {
249249
return "";
@@ -312,7 +312,15 @@ public String hxReplaceUrlFalse() {
312312
}
313313

314314
@GetMapping("/hx-reswap")
315-
@HxReswap(value = HxSwapType.INNER_HTML, swap = 300)
315+
@HxReswap(value = HxSwapType.INNER_HTML,
316+
swap = 0,
317+
settle = 500,
318+
scroll = HxReswap.Position.TOP,
319+
scrollTarget = "#scrollTarget",
320+
show = HxReswap.Position.BOTTOM,
321+
showTarget = "#showTarget",
322+
transition = true,
323+
focusScroll = HxReswap.FocusScroll.TRUE)
316324
@ResponseBody
317325
public String hxReswap() {
318326
return "";

0 commit comments

Comments
 (0)