Preact: Element ordering after rerender is wrong sometimes

Created on 2 Jun 2016  路  6Comments  路  Source: preactjs/preact

Hi,
I have seen a bug that is happening in weird places that the order of items rendered gets switched up
I have code similar to:

<div>
 {logic && <div>...</div>}
 {!logic && <h1>...</h1>}
 <Wrapper>...</Wrapper>
</div>

when it renders first time its fine but if it rerenders with the logic changed it sometimes reverses the order of the 2 items that come out, this is really difficult to reproduce, was trying yesterday but could not come up with anything

This happens in many places, sometimes a form field gets pushed down or modal title ends up at the bottom etc.

I will try again today to have a repro of this problem

bug

Most helpful comment

Fix is up as preact@beta ([email protected]). Thanks again!

All 6 comments

Interesting, that's one I haven't seen yet. Perhaps something to do with recycling...

yes, this is a weird one, I don't think this happened in 4.8 though, maybe that would be a clue in finding what it could be

I have a case that the problem happens every time (beta6), though didn't manage to reproduce the same scenario in jsfiddle yet

when testing on ff got the error: IndexSizeError: Index or size is negative or greater than the allowed amount on the line: https://github.com/developit/preact/blob/7785c5e9a07ebc3651eeb77d76d47d9951ae6b9b/src/dom/index.js#L61

this happens on the same page that has the ordering problem, this could be related, If not I can create a separate issue

Interesting - I'm actually already going to wrap that line in a try block, hopefully that's the bug!

Fix is up as preact@beta ([email protected]). Thanks again!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jescalan picture jescalan  路  3Comments

SabirAmeen picture SabirAmeen  路  3Comments

matuscongrady picture matuscongrady  路  3Comments

paulkatich picture paulkatich  路  3Comments

rajaraodv picture rajaraodv  路  3Comments