Dismissing autocomplete of username


(Harry Grillo) #1

I like the implementation of user tagging that autocompletes usernames after I type a @ symbol. The autocomplete window that pops up, however, is hard to dismiss. Attempts to either use the right-arrow key or clicking the cursor elsewhere in the text before hitting return still autocomplete the first suggested username instead of allowing me to type something arbitrary after an occurrence of @.

For example, on a Discourse powered forum I want to type the following code snippet (using space indentation rather than ticks):

@hello
# more code here

When i enter @hello, I am prompted with the popup. If I hit return immediately, it autocompletes a username. That is fine. But if I click away (say to the end of the second line) and hit return to start a third line, the autocomplete is still filled in. Currently, the only way I have found to bypass this is to manually hit [esc] when the autocomplete shows up.


(Jeff Atwood) #2

Er, what’s the problem, exactly? Use esc to dismiss the autocomplete.

I guess I can see the argument that clicking away from it should dismiss it. I can’t remember if it ever worked this way though, can you @eviltrout?


(Tobias Eigen) #3

I think @redbassett makes a good point - I’ve been struggling with this a bit as well and I wonder how it is affecting less-savvy members - I will ask.

Once I have created my mention I just want to move along and finish writing my post. Instead I often find myself stuck in a popup that I then have to esc out of. Also as I move my cursor around the post while writing… I correct alot as I type.

This is made worse when I mention a group that then prompts me (again and again) how many people I am about to mention that I have to also close. I’d also like that to go away once I finish the mention and move on with writing my post.


(Sam Saffron) #4

I actually have been hitting issues with @completion as well and just compared our implementation with GitHub.

I think we are being too smart.

:arrow_right: should not autocomplete, if it does it means that when an autocomplete window is open only :arrow_left: :arrow_up: and :arrow_down: function as expected. Meaning they move you around the text but :arrow_right: is in a “hijacked” state.

The fix is quite easy, just stop hijacking it. Have arrows always work as arrows. ENTER or click can choose a target just fine.

I also agree that clicking anywhere that is not in the “autocomplete” area should collapse the autocomplete, cursor is no longer in the right spot, makes no sense to have it open.

I vaguely recall “click” away hiding it, but now 100% sure.


(Harry Grillo) #5

@sam is spot on for my opinions on the usability of the dialog. I am used to autocomplete going away when I try to leave the context it is autocompleting without hitting enter (or tab on native apps – obviously not applicable to a web interface).

On the topic of tagging, I also ran into this issue while inside a code block. I see that usernames are not tagged in code, so I feel like disabling the autocomplete dialog in code blocks would make sense.


(Tobias Eigen) #6

FWIW I think this is an edge case. If I know about space indentation then I can also know to remember to use a backtick to avoid some of these well-known oddities about markdown functionality.

Not that you haven’t started a valuable conversation about the UI which I do hope will be fixed. I like @sam’s assessment of the problem and what can be done to fix it - that sounds about right to me.

Edit: That said, this does make sense too :slight_smile:


(Harry Grillo) #7

Yeah, as noted in the follow up, usernames are not tagged in code (which makes perfect sense to me), but the UI would lead one to believe that they are.


(Sam Saffron) #8

OK I just tweaked this so @completions are far less annoying.

  • I can now @sam click anywhere and have it autocomplete collapse

  • I can also I can type @slowt real quick and hit space and stuff is not autocompleted by mistake

  • I can arrow around when an autocomplete box is open and it collapses at the correct time without eating up any arrow keys.


(Joshua Rosenfeld) #9

Hmm, that tweak could change how many people use @completions. If I am typing a response and know the username I wish to mention like @sam I just type it like I did here and it completes before I submit the post. I for one like the fact that I don’t have to make an effort to click on a username when I know it.


(Sam Saffron) #10

I don’t think you are properly following this particular tweak:

There is a user called slowtiger, in the past we used SPACE to trigger autocompletion of words, now only click and ENTER will issue the completion. This means that in no condition do we do the confusing, space causes a word switcharoo.

For those who are accustomed to space should cause a word switcharoo … just train yourself to use ENTER or TAB

Strongly recommend you play with it here, it is now deployed.


(cpradio) #11

Cool. I had a feeling that was what you meant, but I didn’t want to make the assumption. I look forward to playing with these tweaks over the next few days.


(Joshua Rosenfeld) #12

OK, so if I type @sam completely on my keyboard I see it still makes a mention. However if I start typing @codin (codinghorror) and hit space (not tab) it doesn’t finish his name. Sorry for the misunderstanding! I already tab when I want to complete a name, didn’t even know you could use space, so my issue doesn’t actually exist. Thanks!


(Tobias Eigen) #13

Thanks for fixing this, @sa I mean @sam - this is working much better. Great job and much appreciated.

I did notice though that the # autocompletes don’t work the same way as @ autocompletes now - with # you can press space and the autocompete doesn’t close automatically. It blinks away and comes back. You have to hit esc to make it go away completely.

I would prefer it if @ and # mentions worked the same way.


(Sam Saffron) #14

Yes @tgxworld # autocompletes are kind of buggy at the moment …

type

> #<space>t  

Leave an autocomplete window open, you can get into all sorts of weird conditions, I thing that should unconditionally break out of autocomplete, otherwise there is huge chance of edge cases.


(Erlend Sogge Heggen) #15

The following would be a new feature, but I wonder if it’s possible to re-initialise the mention drop-down if you’ve cancelled it by clicking ESC or clicking away, but then resume typing the name.

What can currently happen: I type @cod and accidentally click somewhere, losing focus. I click at the immediate end of of my mention and continue typing: @codingh but now the drop-down is lost for good.


(cpradio) #16

It seems you can, by deleting the last letter you entered for the mention with backspace (or at least it reopened the mention window for me).

My tests were:

Type @cod hit escape
Type ing, no mention popup, okay
Hit Backspace, mention popup returns… interesting

Test 2:

Type @cod hit escape
Hit backspace, mention popup returns

Both tests work with no additional text following the partial mention and with text following the partial mention.


(Harry Grillo) #17

Agreed that analogous to clicking away dismissing, it would make sense from a UI perspective for the popup to reappear when you return to the username. If not immediately, once you type a new character (shouldn’t require backspacing).


(cpradio) #18

I did some testing with Slack and Facebook and they do not work this way. You either have to start adding more characters, or delete a character.

So the only part that Discourse isn’t handling, is when the cursor is moved back to the prior started mention, if more characters (not space) are typed, popup the mention dialog.


(Harry Grillo) #19

Makes sense to me. I’m in favour of adding characters retriggering the popup. I agree that having the popup occur as soon as the cursor enters a username could be very annoying (especially for people who navigate with the arrow keys).


(Alan Tan) #20

I just opened a PR that closes the autocomplete once it encounters a blank string.

I’m hoping to get acceptance tests for autocomplete working. We really need a test suite for all this edge cases.