UI is broken when switch position frequently
jellli opened this issue Β· comments
Working on it
@emilkowalski From what I can see the problem is that the height are used to create the index.
I tested this with clicking top-center
three times, which results in [3, 2, 1]
for heights
. Once I click top-left
once it results in [4, 1, 2, 3]
for heights
. The cause is that the index in heights
is set by the the mounting of the component. Once it changes from top-center
to top-left
3, 2, 1 are getting unmounted, which removes them from heights
. Then they are mounted again in the top left part of the screen which messes up the order.
The usual fix I would suggest is using toasts
as the single source of truth for the orders of the Toasts
and make heights
a map with toast.id
as a key and the height as a value. But the definition contains the information that the current implementation is used for better speed. I would appreciate it if you could take a look at it.