svelte-multiselect icon indicating copy to clipboard operation
svelte-multiselect copied to clipboard

`await tick` instead of `setTimeout`

Open thenbe opened this issue 3 years ago • 3 comments

I was digging through the source code and came across this todo. Perhaps we can use tick instead?

thenbe avatar Jul 27 '22 20:07 thenbe

await tick() is what I tried originally (see https://github.com/janosh/svelte-multiselect/commit/c8f87660908f9f3335ed17b16d7c2c42c2a3eb79#diff-7d86c55b55f23806b2be4051d790e7c775fd5fa4e1ad3fc2da59eb51ce25c0e9L221) but it didn't work. Not sure why. If you have any clues, definitely interested to hear them.

janosh avatar Jul 27 '22 20:07 janosh

Not entirely sure to be honest. In the much simpler component that I was playing around with, tick managed to do the job. Although my component is pretty basic compared to yours, and has far less event listeners. One way to debug this might be to remove the unrelated event listeners in hopes of isolating the issue.

thenbe avatar Jul 28 '22 01:07 thenbe

Thanks, good suggestion. I'm pressed for time atm but if anyone wants to investigate, I'm happy to support.

janosh avatar Jul 28 '22 02:07 janosh

The component started using await tick() in https://github.com/janosh/svelte-multiselect/blob/fd8b37782cd508aacfc8125c6647cefe56144b80/src/lib/MultiSelect.svelte#L264

janosh avatar Nov 14 '22 05:11 janosh