-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[ContextualMenu] Made disabled buttons focusable #4074
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
Merged
lambertwang-zz
merged 9 commits into
microsoft:master
from
lambertwang-zz:magellan/focusableDisabledItems
Feb 23, 2018
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3ec5432
Made disabled buttons focusable
lambertwang-zz 01ae880
Change file
lambertwang-zz e99090b
Fixed test logic
lambertwang-zz a1c0164
Added test failure
lambertwang-zz 8ae04ca
Added isDisabled tests
lambertwang-zz 3c9f4e2
Fixed tslint in test
lambertwang-zz 50644e2
Merge branch 'master' of github.com:OfficeDev/office-ui-fabric-react …
lambertwang-zz dec1a07
Updated DetailsList snapshot
lambertwang-zz 6e9c8a2
Fix typo
lambertwang-zz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
common/changes/office-ui-fabric-react/magellan-focusableDisabledItems_2018-02-22-23-48.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "[ContextualMenu] Disabled buttons are focusable", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "office-ui-fabric-react", | ||
| "email": "law@microsoft.com" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,7 +290,7 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext | |
| { title && <div className={ this._classNames.title } role='heading' aria-level={ 1 }> { title } </div> } | ||
| { (items && items.length) ? ( | ||
| <FocusZone | ||
| {...this._adjustedFocusZoneProps } | ||
| { ...this._adjustedFocusZoneProps } | ||
| className={ this._classNames.root } | ||
| isCircularNavigation={ true } | ||
| allowTabKey={ true } | ||
|
|
@@ -466,11 +466,11 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext | |
| return ( | ||
| <div className={ this._classNames.header } style={ item.style } role='heading' aria-level={ this.props.title ? 2 : 1 }> | ||
| <ChildrenRenderer | ||
| item={item} | ||
| classNames={classNames} | ||
| index={index} | ||
| onCheckmarkClick={hasCheckmarks? this._onItemClick : undefined} | ||
| hasIcons={hasIcons} | ||
| item={ item } | ||
| classNames={ classNames } | ||
| index={ index } | ||
| onCheckmarkClick={ hasCheckmarks ? this._onItemClick : undefined } | ||
| hasIcons={ hasIcons } | ||
| /> | ||
| </div>); | ||
| } | ||
|
|
@@ -492,11 +492,11 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext | |
| onClick={ this._onAnchorClick.bind(this, item) } | ||
| > | ||
| <ChildrenRenderer | ||
| item={item} | ||
| classNames={classNames} | ||
| index={index} | ||
| onCheckmarkClick={hasCheckmarks? this._onItemClick : undefined} | ||
| hasIcons={hasIcons} | ||
| item={ item } | ||
| classNames={ classNames } | ||
| index={ index } | ||
| onCheckmarkClick={ hasCheckmarks ? this._onItemClick : undefined } | ||
| hasIcons={ hasIcons } | ||
| /> | ||
| </a> | ||
| </div>); | ||
|
|
@@ -531,6 +531,10 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext | |
| const defaultRole = canCheck ? 'menuitemcheckbox' : 'menuitem'; | ||
| const itemHasSubmenu = hasSubmenu(item); | ||
|
|
||
| const buttonNativeProperties = getNativeProps(item, buttonProperties); | ||
| // Do not add the deleted attribute to the button so that it is focusable | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo. Not deleted but disabled
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I'll fix that. |
||
| delete (buttonNativeProperties as any).disabled; | ||
|
|
||
| const itemButtonProperties = { | ||
| className: classNames.root, | ||
| onClick: this._onItemClick.bind(this, item), | ||
|
|
@@ -539,7 +543,6 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext | |
| onMouseLeave: this._onMouseItemLeave.bind(this, item), | ||
| onMouseDown: (ev: any) => this._onItemMouseDown(item, ev), | ||
| onMouseMove: this._onItemMouseMove.bind(this, item), | ||
| disabled: this._isItemDisabled(item), | ||
| href: item.href, | ||
| title: item.title, | ||
| 'aria-label': ariaLabel, | ||
|
|
@@ -556,10 +559,16 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext | |
|
|
||
| return ( | ||
| <button | ||
| { ...getNativeProps(item, buttonProperties) } | ||
| { ...buttonNativeProperties } | ||
| { ...itemButtonProperties } | ||
| > | ||
| <ChildrenRenderer item={item} classNames={classNames} index={index} onCheckmarkClick={hasCheckmarks? this._onItemClick : undefined} hasIcons={hasIcons} /> | ||
| <ChildrenRenderer | ||
| item={ item } | ||
| classNames={ classNames } | ||
| index={ index } | ||
| onCheckmarkClick={ hasCheckmarks ? this._onItemClick : undefined } | ||
| hasIcons={ hasIcons } | ||
| /> | ||
| </button> | ||
| ); | ||
| } | ||
|
|
@@ -617,7 +626,7 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext | |
| } as IContextualMenuItem; | ||
| return React.createElement('button', | ||
| getNativeProps(itemProps, buttonProperties), | ||
| <ChildrenRenderer item={item} classNames={classNames} index={index} onCheckmarkClick={hasCheckmarks? this._onItemClick : undefined} hasIcons={hasIcons} />, | ||
| <ChildrenRenderer item={ item } classNames={ classNames } index={ index } onCheckmarkClick={ hasCheckmarks ? this._onItemClick : undefined } hasIcons={ hasIcons } />, | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -640,7 +649,7 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext | |
| onMouseDown: (ev: any) => this._onItemMouseDown(item, ev), | ||
| onMouseMove: this._onItemMouseMove.bind(this, item) | ||
| }), | ||
| <ChildrenRenderer item={item} classNames={classNames} index={index} hasIcons={false} /> | ||
| <ChildrenRenderer item={ item } classNames={ classNames } index={ index } hasIcons={ false } /> | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -821,6 +830,9 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext | |
| } | ||
|
|
||
| private _executeItemClick(item: IContextualMenuItem, ev: React.MouseEvent<HTMLElement>) { | ||
| if (item.disabled || item.isDisabled) { | ||
| return; | ||
| } | ||
| if (item.onClick) { | ||
| item.onClick(ev, item); | ||
| } else if (this.props.onItemClick) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still validate isDisabled, it needs to be removed in 6.0 once it's deprecated.