site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

User Input: Can't Delete Search Terms with Keyboard

Open ivankruchkoff opened this issue 5 years ago • 7 comments

Bug Description

When I fill out search terms, I can't then delete them with the backspace/delete key.

Steps to reproduce

  1. Go to user input flow
  2. Get to 5/5 search terms
  3. Fill out some search terms
  4. Try and delete with backspace
  5. See that search terms don't get deleted

Screenshots

Additional Context

  • PHP Version:
  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Plugin Version [e.g. 22]
  • Device: [e.g. iPhone6]

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • When pressing the backspace key within a search term (i.e. cursor is within the search term bubble), it should delete characters from that search term.
  • When pressing the backspace key when right after a search term (i.e. the cursor is outside a search term bubble, right after one), it should delete that entire search term.

Implementation Brief

  • Once #2842 has been merged, using /assets/js/components/user-input/UserInputKeywords.js,
    • import BACKSPACE from @wordpress/keycodes.
    • create new function deleteKeyword which does the same thing as onKeywordDelete.
    • update onKeywordDelete to use the deleteKeyword function.
    • update the onKeyDown function to:
      • get the length of nonEmptyValues
      • if the length is less than 3 and the BACKSPACE key is pressed, call the deleteKeyword function passing nonEmptyValuesLength - 1 as the index to delete.
      • set the focus to the input text again using the same logic when the ENTER or COMMA keys are pressed, but this time, having the following selector: #${ slug }-keyword-${ nonEmptyValuesLength - 1 }

Test Coverage

N/A

Visual Regression Changes

N/A

QA Brief

  • Fill out the user input flow until you reach step 5 (search terms)
  • You should be able to:
    • Enter up to 3 words, pressing comma or enter/ return to enter a word
    • Delete within a word you are typing (i.e. hitting backspace while typing a word should delete the character you have just typed)
    • Delete a term after entering it (e.g. type test, hit comma to enter it, then testing, hitting comma again. Now hit the the backspace and testing should be removed, but not test).

Changelog entry

  • Fix accessibility problem where it wasn't possible to delete user input search terms using the keyboard.

ivankruchkoff avatar Mar 01 '21 21:03 ivankruchkoff

IB largely looks good but one thing I'm not clear on:

if nonEmptyValues.length is than 3 and the BACKSPACE key is pressed, call the deleteKeyword function passing nonEmptyValuesLength - 1 as the index to delete.

Why does it matter if there are fewer than the max number of keywords entered? Isn't the idea that if you can focus the text field and backspace in an empty bubble/outside a bubble that it deletes no matter what?

I'd think this check would instead be if nonEmptyValues.length is 0—if that's the case we don't delete anything as there's nothing to delete.

tofumatt avatar Mar 11 '21 20:03 tofumatt

@tofumatt As per the AC, When pressing the backspace key within a search term (i.e. cursor is within the search term bubble), it should delete characters from that search term. so if you are at the third item (max. number), if the backspace key is pressed, it should not delete the item, rather it should delete characters from that item.

asvinb avatar Mar 15 '21 12:03 asvinb

Just realised this IB isn't finished, sorry! I'll pause work until it is passed review. My mistake 🙏

johnPhillips avatar Mar 15 '21 15:03 johnPhillips

@asvinb Ah, okay, thanks! Makes sense now. 👍🏻

IB ✅

tofumatt avatar Mar 15 '21 20:03 tofumatt

QA Update: Fail ❌

@johnPhillips when I hit backspace within a word, it will allow me to delete one letter but the cursor then jumps to the end of the word. This is an issue if I am wanting to delete more than one letter within the word. When I hit the backspace once, I should then be able to hit the key again to delete the next letter.

Right now, I have to click backspace once to delete the letter, and then click in the word again next to the next letter I want to delete, and hit backspace again. Here's a quick screencast

https://user-images.githubusercontent.com/73545194/113860473-ac0a0500-97d8-11eb-98fb-661ef1070e25.mp4

Verified:

Delete a term after entering it, is removed. (e.g. type test, hit comma to enter it, then testing, hitting comma again. Now hit the the backspace and testing is removed, but not test).

wpdarren avatar Apr 07 '21 11:04 wpdarren

@johnPhillips and I chatted about this and turns out this was an issue even before this fix landed—the way we store the data for these elements in state and then select them causes a known bug with input cursor jumping with controlled components. I found a fix for this and will have a PR soon… it's arguably almost a separate issue but I'll fix it as part of the QA here. 🙂

tofumatt avatar Apr 07 '21 17:04 tofumatt

QA Update: Pass ✅

On the 5th question, when you enter up to 3 words:

  • User can delete letters within a word.
  • User can delete a term after entering it.
  • Also confirmed that these two tests in the QAB on mobile and tablet devices.

https://user-images.githubusercontent.com/73545194/114394439-c7588400-9bcd-11eb-8f6c-659ba1558671.mov

wpdarren avatar Apr 12 '21 12:04 wpdarren