Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autocomplete: In @-mention results, match insensitively to diacritics #237

Open
chrisbobbe opened this issue Jul 21, 2023 · 6 comments · May be fixed by #588
Open

autocomplete: In @-mention results, match insensitively to diacritics #237

chrisbobbe opened this issue Jul 21, 2023 · 6 comments · May be fixed by #588
Labels
a-compose Compose box, autocomplete, attaching files/images

Comments

@chrisbobbe
Copy link
Collaborator

If there's a user with Étienne in their name, we should still include it in the results for the query etienne.

The matching is already case-insensitive, but it should be insensitive to diacritics too.

@chrisbobbe chrisbobbe added the a-compose Compose box, autocomplete, attaching files/images label Jul 21, 2023
@chrisbobbe chrisbobbe added this to the Launch milestone Jul 21, 2023
@chrisbobbe chrisbobbe changed the title autocomplete: In user-mention results, match insensitively to diacritics autocomplete: In @-mention results, match insensitively to diacritics Jul 21, 2023
@chrisbobbe
Copy link
Collaborator Author

(In principle this should also apply to user-group mentions, not just user mentions. User-group mention autocomplete hasn't been implemented yet: #233.)

@Khader-1
Copy link
Collaborator

Can we use something like diacritic?
BTW I'm new here (and new to open source in general) so what is the policy when it comes to packages and dependencies?

Khader-1 added a commit to Khader-1/zulip-flutter that referenced this issue Mar 25, 2024
Khader-1 added a commit to Khader-1/zulip-flutter that referenced this issue Mar 25, 2024
@gnprice
Copy link
Member

gnprice commented Mar 26, 2024

It looks like that package consists of a hand-maintained set of mappings:
https://github.com/agilord/diacritic/blob/8cc02fb838f69bfffd25a7629787267814669b28/lib/src/replacement_map.dart#L59-L60
with no particular documentation of where the list comes from. So that isn't something I'd be eager to rely on.

The Zulip web client and the legacy zulip-mobile app have functionality like this. So let's implement the same behavior they have.

That behavior has been stable for a long time and I'm not aware of any bug reports we've gotten about it. If we later learn about ways the behavior can be improved, we can make the improvement for web too at the same time.

@Khader-1
Copy link
Collaborator

The Zulip web client and the legacy zulip-mobile app have functionality like this. So let's implement the same behavior they have.

After taking a look back at the mobile app implementation for this feature I found that it depends on @zulip/shared to handle this. check:
file: zulip-mobile/src/users/userHelpers.js

import * as typeahead from '@zulip/shared/js/typeahead';

const loweredFilter = filter.toLowerCase();
const isAscii = /^[a-z]+$/.test(loweredFilter);
return users.filter(user => {
  const full_name = isAscii ? typeahead.remove_diacritics(user.full_name) : user.full_name;
  return user.user_id !== ownUserId && full_name.toLowerCase().startsWith(loweredFilter);
});

Which uses the convenient Js String built in method normalize

file: @zulip/shared/lib/typeahead.js

const unicode_marks = /\p{M}/gu;
export function remove_diacritics(s) {
    return s.normalize("NFKD").replace(unicode_marks, "");
}

Which unfortunately dart does not have for now at least so we might have to consider third party packages, I am still searching and evaluating the options but I found several candidates:

So I will do some research to be able make an educated suggestion

@gnprice gnprice modified the milestones: Launch, B2: Summer 2024 May 9, 2024
@gnprice gnprice added the upstream Would benefit from work in Flutter or another upstream label Nov 22, 2024
@gnprice
Copy link
Member

gnprice commented Nov 23, 2024

Updating this thread with a conclusion from chat and the PR thread #588 (comment) :

We'd use package:unorm_dart for this.

@gnprice gnprice removed the upstream Would benefit from work in Flutter or another upstream label Nov 23, 2024
@chrisbobbe
Copy link
Collaborator Author

When making the search "fuzzy" like this, ideally we'd prioritize non-fuzzy matches over fuzzy matches. (zulip/zulip#32634 gave me the idea to comment here; we can split this to a new issue if helpful.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-compose Compose box, autocomplete, attaching files/images
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

3 participants