medusa-ui/medusa

Button in fragment misses a __FRAGMENT__ replacement on rerender

Closed this issue · 2 comments

In version 0.9.0, when you have a fragment which contains a button, upon rerender it can revert back to __FRAGMENT__

<button class="slot" onclick="_M.doAction(event, '__FRAGMENT__', `doAction(0)`)">Standard damage</button>

instead of

<button class="slot" onclick="_M.doAction(event, 'combat', `doAction(0)`)">Standard damage</button>

I'd need to investigate what specifically causes this

Core of this problem lies in hitting the max depth:

public Flux<DataBuffer> renderFragment(String html, Session session) {
session.setDepth(session.getDepth() + 1);
if(session.getDepth() > 100) {
return Flux.just(FluxUtils.stringToDataBuffer(html));
}
return loadFragments(html, session).flatMapMany(parsedHTML -> {

Which hits 100 pretty fast in my example

Figured out this is caused by not resetting the session depth after rendering. Session resets per page load, but if a page is continuously used, it keeps counting up.
1dd771b