Skip to content

Commit

Permalink
Reduces flickering when re-opening a combobox
Browse files Browse the repository at this point in the history
The flickering occurred, when a combobox was re-opened after a previous
query was performed and an item has been selected.

This is fixed by allowing the dropdown's content to re-render when closed.
The number of calculations stays roughly the same as the results are only
computed when the input data changed.
  • Loading branch information
haukesomm committed Sep 12, 2024
1 parent 736475d commit 389f104
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,10 @@ class Combobox<E : HTMLElement, T>(tag: Tag<E>, id: String?) : Tag<E> by tag, Op
// All subsequent states are computed based on the changing internal state:
data
.drop(1)
.filter { it.opened }
.map { it.items to it.query }
.distinctUntilChanged()
.debounce(inputDebounceMillis)
.mapLatest { state -> computeQueryResult(state.items, state.query) }
.mapLatest { (items, query) -> computeQueryResult(items, query) }
.debounce(renderDebounceMillis)
)

Expand Down

0 comments on commit 389f104

Please sign in to comment.