@mention full name autocomplete doesn't work with international characters


(Noam Yorav-Raphael) #1

Is there any reason @mentions don’t autocomplete using the full name if it’s not in English (specifically, if it’s in Hebrew)? I plan to create a Hebrew forum mostly using full names, and having to switch to English, and remember the username, just to mention somebody is a real pain.

(If it can be fixed and isn’t too complicated, I will be glad to contribute a patch.)

Thanks,
Noam


(Mittineague) #2

Are you sure the problem has to do with “international characters”?
My guess would be it has something more to do with RTL


(Noam Yorav-Raphael) #3

I don’t think it has something to do with RTL - I changed the interface language to English (so everything is LTR) and it didn’t complete just the same.


(Mittineague) #4

It must be the “username must be within Twitter name rules” thing. i.e.

Begin with a-z, contain only a-z or underscore, up to 20 characters.

How did you get to have usernames outside of that?

I think you may need to do whatever you did there to everywhere the code touches the username.


(Noam Yorav-Raphael) #5

I have read in several places that this autocomplete should also complete full names, not only usernames. The full name is Hebrew, the username contains only latin characters.


(Mittineague) #6

Got a link to one of them? I’ve either missed seeing them or don’t remember seeing them.


(Noam Yorav-Raphael) #7

Here’s one:
https://meta.discourse.org/t/username-dont-support-multilanguage-character/8368/4?u=noamraph&source_topic_id=29819


(Mittineague) #8

From the post immediately after that one

https://meta.discourse.org/t/username-dont-support-multilanguage-character/8368/5?u=mittineague&source_topic_id=29819

It seems to work if the member posted in the topic

but not if they haven’t (also, I see the quote above is missing the real name as well)


(Noam Yorav-Raphael) #9

I think it always works. Perhaps there’s precedence for posters in the current topic, but it seems you can find everyone:

It also works on my own installation – I changed my display name to an English one (completely different from the username) and it worked there too.


(Noam Yorav-Raphael) #11

I think I have found the source of the problem. In jsapp/lib/user-search.js.es6 line 91 you have:

    // TODO site setting for allowed regex in username
    if (term.match(/[^a-zA-Z0-9_\.]/)) {

I added א-ת to the regex to include Hebrew characters, and it worked! Now, this is fine by me, but perhaps a more general solution should be used – in fact, I tried removing the entire if block, and it seems to work fine – I can even search a display name that includes a space (I don’t have to use an underscore), so I can just type “@jeff at” and get it completed to @codinghorror and I don’t need to type @jeff_at, which I think most users wouldn’t have tried at all.


(Noam Yorav-Raphael) #12

@eviltrout, would it be ok to remove the if block altogether? You added it in this commit:

https://github.com/discourse/discourse/commit/3b76fd82fd9b00f71c5b2424e8086fd82e516cdc


(Itzik Arzoni) #13

I would like this fix to be integrated into discourse.


(Sam Saffron) #14

סבבה, as long as there are no undesired side effects


(Noam Yorav-Raphael) #15

I’m proud to submit my first pull request! I didn’t find any undesired side effects.

https://github.com/discourse/discourse/pull/3540


(Gerhard Schlager) #16

I’m not sure that it was wise to remove the entire regex. Shouldn’t we at least stop the autocomplete when a space is entered?

With this change I need to explicitly select an entry from the autocomplete dialog with the enter key.
Otherwise the autocomplete dialog shows up when I write someones name followed by a space even if the mentioned name matches an existing user.

For example @sam followed by a space results in this:

Either stop matching when a space is entered or don’t show the autocomplete dialog when there’s already an exact match on the name and a space was entered.


(Jeff Atwood) #17

Ok, reverting this for now, then.


(Sam Saffron) #18

Definitely should stop on any space. I think it is safe to match on non space.


(Noam Yorav-Raphael) #19

Are you sure the autocomplete should stop on any space? The new (reverted) behaviour lets you mention @codinghorror by typing @jeff atwood and pressing Enter, but would still allow you to mention @jeff by typing “@jeff how are you”. The only thing slightly peculiar is that the autocomplete list remains open after you typed @jeff and a space. I think the list wouldn’t even be shown to most users, as they won’t pause after the space. And if the list does get shown, they can just ignore it and continue typing.

The advantage is that you can use autocomplete to find the user you want by his full name, even if there are multiple users with the same first name. Indeed, you can do this anyway by using an underscore, but I guess many users won’t discover that.


(Jeff Atwood) #20

Space shouldn’t be used here.

It is a bit indeterminate since you can match username (ascii, a-z, no spaces) and full name (unicode, spaces, etc) in the same mechanism – so I can support making sure unicode character ranges are the regex – but matching space is super undesirable.

Or maybe the regex should be “hit a space or end of line”.


(Noam Yorav-Raphael) #21

Can you elaborate on what’s the problem with that? As I said, the only thing that I see is that it’s a bit weird that if you type @jeff and a space, and then pause, the list remains open. But I don’t see any functionality problem with that. I think this is a small price to pay for being able to search for users by their full name (in case they have a common first name).