Skip to content

Added enum for triggering menu with arrow keys and bool to allow it or not#3950

Merged
dzearing merged 7 commits intomicrosoft:masterfrom
eikawata:add-menu-trigger-button-configuration
Feb 16, 2018
Merged

Added enum for triggering menu with arrow keys and bool to allow it or not#3950
dzearing merged 7 commits intomicrosoft:masterfrom
eikawata:add-menu-trigger-button-configuration

Conversation

@eikawata
Copy link
Copy Markdown

Pull request checklist

Description of changes

Added a enum for specifying which arrow key is used to trigger button menu. Also, added a boolean value indicating whether triggering menu using arrow keys is allowed.

Focus areas to test

Ensure button menu can open using keyboards. Also, verify split buttons behaviors didn't regress.

@autobind
private _onMenuKeyDown(ev: React.KeyboardEvent<HTMLElement>) {
if (ev.which === KeyCodes.down) {
if (this.props.allowDirectionalMenuTrigger && ev.which === this._getDirectionKeyCode()) {
Copy link
Copy Markdown
Collaborator

@manishgarg1 manishgarg1 Feb 12, 2018

Choose a reason for hiding this comment

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

allowDirectionalMenuTrigger [](start = 19, length = 27)

I looked at the PR and was thinking if we actually need this boolean. Just the presence of the menuTriggerDirection is enough to confirm that the consumer wants to controll the key to use. No?
#Resolved

Copy link
Copy Markdown
Member

@dzearing dzearing Feb 12, 2018

Choose a reason for hiding this comment

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

What if we renamed this prop to menuTriggerKeyCode and simply use the KeyCode enum as its type?
#Resolved

Copy link
Copy Markdown
Author

@eikawata eikawata Feb 12, 2018

Choose a reason for hiding this comment

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

@manishgarg1 , My reasoning is that, since the current default behavior is to allow triggering menu with arrow down, I wanted to also enable it and set the default key to be arrow down. Hence, the bool value was needed to explicitly turn it off. I can of course make the prop KeyCodes | null, then disable it when it's set to null. But that sounds unintuitive when not specifying the prop defaults to arrow down.

@dzearing , I thought about that, but I personally felt being able to assign a random key to trigger a menu sounded odd, especially when pressing Enter/Space on a button already triggers a menu. If we are going to keep the bool value, then setting it to false still doesn't disable the Enter/Space key to open the menu.

Copy link
Copy Markdown
Collaborator

@manishgarg1 manishgarg1 Feb 13, 2018

Choose a reason for hiding this comment

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

@ekawatani, exactly as you said. I would prefer "KeyCodes | undefined" as the API signature. And remove the bool. I will confirm with David if he is good with that. #Resolved

Copy link
Copy Markdown
Author

@eikawata eikawata Feb 14, 2018

Choose a reason for hiding this comment

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

@manishgarg1 , Thanks. I can remove the bool, and convert the other prop to use KeyCode as David suggested earlier. Just making sure, but we still want to maintain the default behavior to be keydown, correct? So, to disable the custom menu trigger would be to manually assign null to the prop.

Let me know if this is what we want, and I'll send an update. #Resolved

Copy link
Copy Markdown
Collaborator

@manishgarg1 manishgarg1 Feb 14, 2018

Choose a reason for hiding this comment

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

Hi @ekawatani , Yes we would like the default behaviour to be keydown. The default value for your new property would be 'undefined' if the consumer code does not set that property. Does that explain the expected behaviour?

Further, just rename the prop to menuTriggerKeyCode as David mentioned above. #Resolved

@manishgarg1 manishgarg1 self-assigned this Feb 12, 2018

/**
* Defines a custom key that opens button menu. If the value is not provided, down arrow key is used.
* If set to null, this will be disabled.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Provides a custom KeyCode that can be used to open the button menu. The default keyCode is the down arrow. A value of null can be provided to disable the key codes for opening the button menu.

@dzearing dzearing closed this Feb 16, 2018
@dzearing dzearing reopened this Feb 16, 2018
@dzearing
Copy link
Copy Markdown
Member

Resetting the build...

@dzearing dzearing merged commit 2bdbb7e into microsoft:master Feb 16, 2018
@eikawata eikawata deleted the add-menu-trigger-button-configuration branch February 16, 2018 08:50
Markionium added a commit to Markionium/office-ui-fabric-react that referenced this pull request Feb 18, 2018
* master: (71 commits)
  Applying package updates.
  Delete initials_2018-02-07-13-49.json
  Delete initials_2018-02-07-13-49.json
  Delete jolore-addingWorkWeekDateRange_2018-01-24-01-39.json
  Delete initials_2018-02-07-13-49.json
  Delete jolore-addingWorkWeekDateRange_2018-01-24-01-39.json
  Delete initials_2018-02-07-13-49.json
  Update .npmrc
  Cleaning Up Console Log in CommandBar Test (microsoft#4011)
  Convert Overlay to mergeStyles (microsoft#3978)
  ScrollablePane SCSS to MergeStyles Part 1: File Structure (microsoft#4008)
  [ContextualMenu] Fixes useTargetWidth property (microsoft#3943)
  DetailsList: Consider groups when setting aria-rowcount
  List: Add a _notifyPageChanges function  (microsoft#3990)
  Applying package updates.
  Migrating Coachmark to main Package, Added a beak component and updated experiment PositioningContainer. (microsoft#3919)
  Update package.json
  Added enum for triggering menu with arrow keys and bool to allow it or not (microsoft#3950)
  BaseExtendedPicker: Hook up onPaste (microsoft#3885)
  FocusUtil: fix getPreviousElement to include previous sibling elements correctly (microsoft#3928)
  ...
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The key used to open button menu should be configurable

3 participants