Skip to content

Dropdown: refine handling of keydown in input and textarea#21802

Closed
pvdlg wants to merge 8 commits intotwbs:v4-devfrom
pvdlg:dropdown-input-textarea
Closed

Dropdown: refine handling of keydown in input and textarea#21802
pvdlg wants to merge 8 commits intotwbs:v4-devfrom
pvdlg:dropdown-input-textarea

Conversation

@pvdlg
Copy link
Copy Markdown
Contributor

@pvdlg pvdlg commented Jan 21, 2017

Fixes #21366

This PR handle better the key inputs in input and textarea within dropdown and dropdown-menu.
As a side note, keyboard navigation is current broken and the fix is here #21535.

This PR will be fully working only when #21535 lands.

Here is the new behaviors.

input and textarea within a dropdown-menu:

  • Escape key: dropdown behavior => close the menu
  • Arrow down: default behavior (move to the cursor to the end of the text in the input or textarea)
  • Arrow up: default behavior => move to the cursor to the beginning of the text in the input or textarea
  • Space key: default behavior => enter a space character in the input or textarea
  • Other key: default behavior => enter the character in the input or textarea

input and textarea within a dropdown but outside of the dropdown-menu:

  • Escape key: dropdown behavior => close the menu
  • Arrow down: dropdown behavior => put the focus on the first/next dropdown-item in the menu
  • Arrow up: dropdown behavior => put the focus on the first/previous dropdown-item in the menu
  • Space key: default behavior => enter a space character in the input or textarea
  • Other key: default behavior => enter the character in the input or textarea

Copy link
Copy Markdown
Member

@Johann-S Johann-S left a comment

Choose a reason for hiding this comment

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

LGTM 👍

But we have to review this #21535 first

@Johann-S
Copy link
Copy Markdown
Member

Can you update your branch @vanduynslagerp ? Thank you 👍

@mdo mdo modified the milestones: v4.0.0-beta, v4.0.0-beta.2 Apr 16, 2017
Copy link
Copy Markdown
Member

@Johann-S Johann-S left a comment

Choose a reason for hiding this comment

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

Your unit test failed because of the lack of .dropdown-item and li isn't focusable without tabindex="1"

With this HTML everything is fine :

      <ul class="tabs">
        <li class="dropdown">
          <input type="text" id="input" data-toggle="dropdown">
          <ul class="dropdown-menu" role="menu">
            <li id="item1" tabindex="1" class="dropdown-item"><a href="#">Secondary link</a></li>
            <li id="item2" tabindex="1" class="dropdown-item"><a href="#">Something else here</a></li>
            <li class="divider"/>
            <li tabindex="1" class="dropdown-item"><a href="#">Another link</a></li>
          </ul>
        </li>
      </ul>

@mdo mdo removed this from the v4.0.0-beta.2 milestone Jun 18, 2017
@mdo
Copy link
Copy Markdown
Member

mdo commented Oct 18, 2017

@Johann-S I pushed the class name change but tests are still failing. Any chance you could take a look?

@Johann-S
Copy link
Copy Markdown
Member

Superseded by : #24557

@Johann-S Johann-S closed this Oct 26, 2017
Comment thread js/src/dropdown.js
// - And not a key in REGEXP_KEYDOWN => not a dropdown command
// If input/textarea:
// - If space key => not a dropdown command
// - If key is other than excape
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

escape

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants