-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Have optional callback in focusZoneProps to determine if scenario owner wants the input element to lose the focus on arrow key #4290
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
Changes from all commits
b6e47f9
a3e9c76
cd8705b
262634f
e229a77
ed17e96
abd0b7a
c1c3da1
446d2e6
995f35b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "Add shouldInputLoseFocusOnArrowKey callback for scenario to determine if input should loose focus when arrow key is present when Tabbing is enabled on All elements or Input elements", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "office-ui-fabric-react", | ||
| "email": "sayalis@microsoft.com" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "FocusZone: adding `shouldInputLoseFocusOnArrowKey` optional callback for scenarios where user press an arrow key on an input element and want it to loose focus when FocusZone disables moving focus away in case when FocusZoneTabbableElements is set to All or none", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "office-ui-fabric-react", | ||
| "email": "sayalis@microsoft.com" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -804,12 +804,17 @@ export class FocusZone extends BaseComponent<IFocusZoneProps, {}> implements IFo | |
| // We shouldn't lose focus in the following cases: | ||
| // 1. There is range selected. | ||
| // 2. When selection start is larger than 0 and it is backward. | ||
| // 3. when selection start is not the end of lenght and it is forward. | ||
| // 3. when selection start is not the end of length and it is forward. | ||
| // 4. We press any of the arrow keys when our handleTabKey isn't none or undefined (only losing focus if we hit tab) | ||
| if (isRangeSelected || | ||
| // and if shouldInputLoseFocusOnArrowKey is defined, if scenario prefers to not loose the focus which is determined by calling the | ||
| // callback shouldInputLoseFocusOnArrowKey | ||
| if ( | ||
| isRangeSelected || | ||
| (selectionStart > 0 && !isForward) || | ||
| (selectionStart !== inputValue.length && isForward) || | ||
| !!this.props.handleTabKey) { | ||
| (!!this.props.handleTabKey && !(this.props.shouldInputLoseFocusOnArrowKey | ||
| && this.props.shouldInputLoseFocusOnArrowKey(element))) | ||
|
Member
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. is it possible to add a unit test to cover this scenario so we don't break it in the future?
Member
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. (it's super easy, go to the packages/oufr folder, run
Collaborator
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.
Collaborator
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. Nevermind Joe told me what oufr means :D
Collaborator
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. Added test |
||
| ) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.
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.
As a consumer I can't make sense of the reasoning here. Can you fix some of the language? This comment goes into release notes (and it can be markdown, so use backticks around property names.)
FocusZone: adding
shouldInputLoseFocusOnArrowKeyoptional callback for scenarios where the user presses an arrow key on an input element, but we would want to disable moving focus away.That's just an idea but maybe you could help refine the language.
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.
Oh good to know. Thanks David. I have updated the change log.