Skip to content

Commit

Permalink
Fixed Combo and AssetCombo flashing.
Browse files Browse the repository at this point in the history
  • Loading branch information
lpaolini committed Mar 12, 2024
1 parent ed7c18a commit 423bb94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions modules/gui/src/widget/assetCombo.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ class _AssetCombo extends React.Component {
initializeSearch() {
const {addSubscription, mode} = this.props
addSubscription(
this.filter$.pipe(
debounceTime(100)
).subscribe(
this.filter$.subscribe(
({filter, filterReset}) => this.setState(({filter: prevFilter}) => ({
filter: filterReset ? prevFilter : filter,
highlightMatcher: getHighlightMatcher(filter),
Expand Down
8 changes: 5 additions & 3 deletions modules/gui/src/widget/combo.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import React from 'react'
import _ from 'lodash'
import styles from './combo.module.css'

const SIMPLIFY_STRING_CONFIG = {trim: true, removeAccents: true, removePunctuation: false, removeNonAlphanumeric: false, removeRepeatedSpaces: true}

const mapStateToProps = state => ({
dimensions: selectFrom(state, 'dimensions') || []
})
Expand Down Expand Up @@ -393,14 +395,14 @@ class _Combo extends React.Component {

matcher(filter) {
// match beginning of multiple words in any order (e.g. both "u k" and "k u" match "United Kingdom")
const matchers = splitString(simplifyString(escapeRegExp(filter), {removeNonAlphanumeric: false}))
const matchers = splitString(simplifyString(escapeRegExp(filter), SIMPLIFY_STRING_CONFIG))
.map(part => part ? `(?=.*${(part)})` : '') // regexp positive lookahead ("?=")
return RegExp(`^${matchers.join('')}.*$`, 'i')
}

filterOptions(group) {
const {matcher} = this.state
const isMatchingGroup = matcher.test(simplifyString(group.searchableText || group.label))
const isMatchingGroup = matcher.test(simplifyString(group.searchableText || group.label, SIMPLIFY_STRING_CONFIG))
const filterOptions = _.isFunction(group.filterOptions)
? group.filterOptions(isMatchingGroup)
: group.filterOptions !== false
Expand All @@ -424,7 +426,7 @@ class _Combo extends React.Component {
? null
: options.forceFilter === true
? option
: matcher.test(simplifyString(option.searchableText || option.label))
: matcher.test(simplifyString(option.searchableText || option.label, SIMPLIFY_STRING_CONFIG))
? option
: null
)
Expand Down

0 comments on commit 423bb94

Please sign in to comment.