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

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

Closed
wants to merge 8 commits into from

Conversation

pvdlg
Copy link
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
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
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
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
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
Member

Superseded by : #24557

@Johann-S Johann-S closed this Oct 26, 2017
// - 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
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