Skip to content

Commit 860ca7e

Browse files
authored
FocusZone: respect home/end when in INPUT or TEXTAREA (#2547)
* fixing textfield home/end in focuszone * Adding change file.
1 parent c191678 commit 860ca7e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "office-ui-fabric-react",
5+
"comment": "FocusZone: presssing home/end inside of an input/textarea element should respect cursor location.",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "office-ui-fabric-react",
10+
"email": "[email protected]"
11+
}

packages/office-ui-fabric-react/src/components/FocusZone/FocusZone.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,24 @@ export class FocusZone extends BaseComponent<IFocusZoneProps, {}> implements IFo
343343
return;
344344

345345
case KeyCodes.home:
346+
if (
347+
this._isElementInput(ev.target as HTMLElement) &&
348+
!this._shouldInputLoseFocus(ev.target as HTMLInputElement, false)) {
349+
return false;
350+
}
346351
const firstChild = this.refs.root.firstChild as HTMLElement;
347352
if (this.focusElement(getNextElement(this.refs.root, firstChild, true) as HTMLElement)) {
348353
break;
349354
}
350355
return;
351356

352357
case KeyCodes.end:
358+
if (
359+
this._isElementInput(ev.target as HTMLElement) &&
360+
!this._shouldInputLoseFocus(ev.target as HTMLInputElement, true)) {
361+
return false;
362+
}
363+
353364
const lastChild = this.refs.root.lastChild as HTMLElement;
354365
if (this.focusElement(getPreviousElement(this.refs.root, lastChild, true, true, true) as HTMLElement)) {
355366
break;

0 commit comments

Comments
 (0)