Skip to content

Provide more predictable fuzzy matching#11309

Merged
kmcgrady merged 3 commits intodevelopfrom
fix/more-predictable-fuzzy-matching
May 9, 2025
Merged

Provide more predictable fuzzy matching#11309
kmcgrady merged 3 commits intodevelopfrom
fix/more-predictable-fuzzy-matching

Conversation

@kmcgrady
Copy link
Copy Markdown
Collaborator

@kmcgrady kmcgrady commented May 8, 2025

Describe your changes

This change migrates away from fzy.js to vendored code with small modifications/improvements including types, and handling case sensitivity (It's MIT licensed).

Also minor, but the sorting for the options is using the negative filter rather than reversing the list. This keeps the sorting more stable and not move options completely around (minor perf benefit).

GitHub Issue Link (if applicable)

closes #11218

Testing Plan

  • JS unit tests added for the predictable searching as well as the fzy.js including case sensitivity logic

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@kmcgrady kmcgrady added security-assessment-completed change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels May 8, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented May 8, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-11309/streamlit-1.45.0-py3-none-any.whl
🕹️ Preview app pr-11309.streamlit.app (☁️ Deploy here if not accessible)

@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented May 8, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented May 8, 2025

📉 Frontend coverage change detected

The frontend unit test (vitest) coverage has decreased by 0.0000%

  • Current PR: 85.8700% (41678 lines, 5887 missed)
  • Latest develop: 85.8700% (41677 lines, 5887 missed)

✅ Coverage change is within normal range.

📊 View detailed coverage comparison

Copy link
Copy Markdown
Collaborator

@raethlein raethlein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just left a minor comment about that we might want to mention that some code portions were originally licensed as MIT

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could we have a small comment here about why we use -? Something like // we use the negative score here because we want the list to be reversed. We don't reverse it in the end because that can lead to UI shuffling. (if I understood it correctly from your PR description)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* App/Models/Order is better than App/MOdels/zRder */
/* app/models/order is better than app/models/zrder */

nit: Could you leave a comment here about the why it is better? I assume its because the o in order comes before the z in zrder.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if these tests are copied 1:1 from fuzzy, I think we should mention it here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is a substantial copy of the code, I think we should keep the MIT license notice or mention the MIT-licensing here.

@kmcgrady kmcgrady force-pushed the fix/more-predictable-fuzzy-matching branch from e876a2c to affba46 Compare May 9, 2025 04:41
@kmcgrady kmcgrady merged commit febcf6b into develop May 9, 2025
37 of 39 checks passed
@kmcgrady kmcgrady deleted the fix/more-predictable-fuzzy-matching branch May 9, 2025 14:58
kmcgrady added a commit that referenced this pull request Oct 22, 2025
## Describe your changes

When working on #11309, I was working to provide more predictable case
sensitive search. It works in some cases (where the case sensitive
should come before a case insensitive), but it made fuzzy searching
across other instances worse (See #11724) In the end, we will go for
case insensitive search, because that's a little more intuitive as users
type and will be less great from a case sensitivity.

I think the scoring could be better in that case insensitive can be
slightly behind a case sensitive match, but that's a much tougher
problem to solve. This will alleviate user's concerns

## GitHub Issue Link (if applicable)

closes #11724

## Testing Plan

- Added a unit test based on the issue's use case

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

st.multiselect reorders options in an unclear/unpredictable way when filtering

2 participants