FocusZone: restore focus on removing item.#7818
FocusZone: restore focus on removing item.#7818dzearing merged 29 commits intomicrosoft:masterfrom dzearing:focuszone
Conversation
…ric-react into focuszone # Conflicts: # packages/office-ui-fabric-react/src/components/FocusTrapZone/FocusTrapZone.test.tsx # packages/utilities/src/focus.ts
packages/office-ui-fabric-react/src/components/FocusTrapZone/FocusTrapZone.test.tsx
Show resolved
Hide resolved
packages/office-ui-fabric-react/src/components/FocusTrapZone/FocusTrapZone.test.tsx
Outdated
Show resolved
Hide resolved
packages/office-ui-fabric-react/src/components/FocusZone/FocusZone.tsx
Outdated
Show resolved
Hide resolved
|
|
||
| element = isElementTabbable(element) | ||
| ? element | ||
| : getNextElement(this._root.current as HTMLElement, element, true) || getPreviousElement(this._root.current as HTMLElement, element)!; |
There was a problem hiding this comment.
Seeing a ! always makes me wary. Can it actually be undefined here? Other functions that do call this one dereference this function's return value, so it could cause an exception...
packages/office-ui-fabric-react/src/components/FocusZone/FocusZone.tsx
Outdated
Show resolved
Hide resolved
packages/office-ui-fabric-react/src/components/FocusZone/FocusZone.tsx
Outdated
Show resolved
Hide resolved
packages/office-ui-fabric-react/src/components/FocusZone/FocusZone.tsx
Outdated
Show resolved
Hide resolved
…ixes to not fire active change events when the active element doesn't change.
| ? element | ||
| : getNextElement(this._root.current as HTMLElement, element, true) || getPreviousElement(this._root.current as HTMLElement, element)!; | ||
|
|
||
| return element as HTMLElement; |
There was a problem hiding this comment.
element should already be an HTMLElement
There was a problem hiding this comment.
It's possibly null. this._root.current! would more clearly communicate that.
| } | ||
| }; | ||
|
|
||
| private _setParkedFocus(isParked: boolean): void { |
There was a problem hiding this comment.
Is parked focus just when focus is at the root/highest thing?
There was a problem hiding this comment.
yes, this is a feature Thomas asked for where if you remove the last item in a zone, we put focus on the parent. Then when new focusables are added, we try and restore focus within the zone.
packages/office-ui-fabric-react/src/components/FocusZone/FocusZone.tsx
Outdated
Show resolved
Hide resolved
|
🎉 Handy links: |
|
🎉 Handy links: |
Pull request checklist
$ npm run changeDescription of changes
When focus is lost from the FocusZone due to the item being removed, FocusZone will now move the focus to the item closest to the previously focused element.
Microsoft Reviewers: Open in CodeFlow