Skip to content

Conversation

@ahmed-saber
Copy link
Contributor

  • Add support for object arrays with separate text and value properties
  • Enable search functionality within both text and value fields
  • Maintain full backward compatibility with existing string arrays
  • Add helper functions: getOptionText(), getOptionValue(), getSearchableContent()
  • Update filtering logic to handle both string and object formats
  • Create comprehensive example (28_autocomplete_text_value_objects.html)
  • Bump version to 10.3.0

- Add support for object arrays with separate `text` and `value` properties
- Enable search functionality within both text and value fields
- Maintain full backward compatibility with existing string arrays
- Add helper functions: getOptionText(), getOptionValue(), getSearchableContent()
- Update filtering logic to handle both string and object formats
- Create comprehensive example (28_autocomplete_text_value_objects.html)
- Bump version to 10.3.0
@josdejong
Copy link
Owner

Thanks Ahmed for this PR, I'll look into it next week.

@ahmed-saber
Copy link
Contributor Author

ahmed-saber commented Jul 28, 2025

@josdejong I hope you can merge it soon, as I'm working on a feature that depends on these changes. Please remember to update the TypeScript for the library as well

@josdejong
Copy link
Owner

I expect to be able to look into it coming Thursday or Friday.

Updating the types will require a separate PR at DefinitelyTyped I think.

Copy link
Owner

@josdejong josdejong left a comment

Choose a reason for hiding this comment

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

Thanks for your PR @ahmed-saber . It looks well taken care of!

I made a couple of inline comments, can you have a look at those?

Also, just as a reminder: we'll need to update the type definitions in definitelytyped/types/jsoneditor after this PR is merged and published.

feat: enhance autocomplete functionality with support for object arrays and multiple searchable fields
Copy link
Owner

@josdejong josdejong left a comment

Choose a reason for hiding this comment

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

Thanks for all the updates, I think the PR is almost ready to be finished. Can you have a look at the new inline comments?

Copy link
Owner

@josdejong josdejong left a comment

Choose a reason for hiding this comment

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

Thanks for your latest updates Ahmed. Here a few more comments.

Refactored autocomplete logic to better support searching across multiple fields and improved match highlighting in dropdowns and hints. Added consistent case normalization and enhanced hint display to prioritize matches that start with the search token for improved user experience.
@ahmed-saber ahmed-saber force-pushed the develop branch 2 times, most recently from 3f6f6e2 to 425eb9a Compare August 1, 2025 10:15
@ahmed-saber ahmed-saber force-pushed the develop branch 2 times, most recently from 664d88b to 8066595 Compare August 1, 2025 13:56
@josdejong
Copy link
Owner

Thanks for the updates @ahmed-saber!

I tested the examples again, there is one odd issue: in example 28_autocomplete_text_value_objects.html, I see the config filter: 'contain', so I would expect to be able to enter something halfway the value/text of an option. When I enter "h" I get two options "Alphabet Inc. (Google)" and "PayPal Holdings Inc.", as expected. But when I enter a second letter "ho" from "holdings", there are no autocompletion options whereas I would expect one match: "PayPal Holdings Inc.". I also cannot search text halfway a value, like entering "ZN" from "AMZN" - no hits. Any idea?

@josdejong
Copy link
Owner

Similarly, in example 29_autocomplete_multiple_fields.html, when I enter "ber" I get two options "Germany" and "Australia" as expected, but when I keep typing and make it "berlin", I get zero autocomplete options wheras I still would expect "Germany".

Replaces manual case checks with a normalizeCase utility for consistent case sensitivity logic throughout the autocomplete component. This improves maintainability and ensures uniform behavior for filtering and hint generation.
@ahmed-saber
Copy link
Contributor Author

I found the line was causing if (rows.length < 2) return The autocomplete with filter: 'contain' should now work exactly as expected.

Copy link
Owner

@josdejong josdejong left a comment

Choose a reason for hiding this comment

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

Ah, now I understand what's going on: when the token matches halfway a value, the hintText cannot autocomplete the "rest" of the value because we're not at the start. Showing the dropdown in case of a single match too (rows.length < 2) makes sense 👍.

I think we can merge the PR now, thanks for all your work!

@josdejong josdejong merged commit 51359b5 into josdejong:develop Aug 1, 2025
5 checks passed
@josdejong
Copy link
Owner

Published now in v10.3.0 🎉

@ahmed-saber
Copy link
Contributor Author

Please remember to update the version of the types as well

@josdejong
Copy link
Owner

Please remember to update the version of the types as well

I have no control over DefinitelyTyped/DefinitelyTyped#73377, we have to await until it is reviewed and merged. I guess you'll have to use @ts-ignore for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants