Skip to content

FocusZone: restore focus on removing item.#7818

Merged
dzearing merged 29 commits intomicrosoft:masterfrom
dzearing:focuszone
Jan 31, 2019
Merged

FocusZone: restore focus on removing item.#7818
dzearing merged 29 commits intomicrosoft:masterfrom
dzearing:focuszone

Conversation

@dzearing
Copy link
Copy Markdown
Member

@dzearing dzearing commented Jan 28, 2019

Pull request checklist

Description 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

@dzearing dzearing assigned JasonGore and unassigned leddie24 Jan 28, 2019
@size-auditor
Copy link
Copy Markdown

size-auditor bot commented Jan 28, 2019

Bundle test Size (minified) Diff from master
GroupedList 179.043 kB ExceedsTolerance     1.501 kB
DocumentCard 275.368 kB ExceedsTolerance     1.501 kB
Pivot 231.156 kB ExceedsTolerance     1.501 kB
Pickers 323.692 kB ExceedsTolerance     1.501 kB
DatePicker 244.58 kB ExceedsTolerance     1.501 kB
DetailsList 254.585 kB ExceedsTolerance     1.501 kB
Dialog 238.467 kB ExceedsTolerance     1.501 kB
Panel 235.829 kB ExceedsTolerance     1.501 kB
OverflowSet 83.998 kB ExceedsTolerance     1.501 kB
Nav 231.961 kB ExceedsTolerance     1.501 kB
MessageBar 231.829 kB ExceedsTolerance     1.501 kB
ComboBox 282.135 kB ExceedsTolerance     1.501 kB
Dropdown 265.59 kB ExceedsTolerance     1.501 kB
ExtendedPicker 210.411 kB ExceedsTolerance     1.501 kB
Facepile 258.914 kB ExceedsTolerance     1.501 kB
FloatingPicker 348.868 kB ExceedsTolerance     1.501 kB
KeytipLayer 208.334 kB ExceedsTolerance     1.501 kB
Keytip 192.684 kB ExceedsTolerance     1.501 kB
FocusZone 76.732 kB ExceedsTolerance     1.501 kB
Grid 225.68 kB ExceedsTolerance     1.501 kB
CommandBar 243.593 kB ExceedsTolerance     1.501 kB
ContextualMenu 189.777 kB ExceedsTolerance     1.501 kB
Rating 116.957 kB ExceedsTolerance     1.501 kB
ShimmeredDetailsList 269.475 kB ExceedsTolerance     1.501 kB
Breadcrumb 243.333 kB ExceedsTolerance     1.501 kB
Button 222.28 kB ExceedsTolerance     1.501 kB
TeachingBubble 233.489 kB ExceedsTolerance     1.501 kB
SwatchColorPicker 241.088 kB ExceedsTolerance     1.501 kB
Calendar 177.9 kB ExceedsTolerance     1.501 kB
SpinButton 235.89 kB ExceedsTolerance     1.501 kB
SelectedItemsList 281.333 kB ExceedsTolerance     1.501 kB
SearchBox 228.595 kB ExceedsTolerance     1.501 kB
Divider 90.505 kB ExceedsBaseline     432 bytes
ChoiceGroup 111.563 kB ExceedsBaseline     432 bytes
ChoiceGroupOption 105.879 kB ExceedsBaseline     432 bytes
Checkbox 109.077 kB ExceedsBaseline     432 bytes
HoverCard 134.087 kB ExceedsBaseline     432 bytes
Check 100.362 kB ExceedsBaseline     432 bytes
Callout 122.99 kB ExceedsBaseline     432 bytes
Fabric 91.335 kB ExceedsBaseline     432 bytes
Coachmark 131.757 kB ExceedsBaseline     432 bytes
FocusTrapZone 68.005 kB ExceedsBaseline     432 bytes
Color 73.275 kB ExceedsBaseline     432 bytes
ColorPicker 138.675 kB ExceedsBaseline     432 bytes
Autofill 68.953 kB ExceedsBaseline     432 bytes
Utilities 63.613 kB ExceedsBaseline     432 bytes
Layer 96.979 kB ExceedsBaseline     432 bytes
Icon 97.61 kB ExceedsBaseline     432 bytes
Popup 66.155 kB ExceedsBaseline     432 bytes
Toggle 101.249 kB ExceedsBaseline     432 bytes
ThemeGenerator 80.794 kB ExceedsBaseline     432 bytes
TextField 121.463 kB ExceedsBaseline     432 bytes
Sticky 71.054 kB ExceedsBaseline     432 bytes
Spinner 92.92 kB ExceedsBaseline     432 bytes
Slider 100.144 kB ExceedsBaseline     432 bytes
Shimmer 101.864 kB ExceedsBaseline     432 bytes
Selection 78.601 kB ExceedsBaseline     432 bytes
ScrollablePane 99.779 kB ExceedsBaseline     432 bytes
ResizeGroup 69.065 kB ExceedsBaseline     432 bytes
ProgressIndicator 93.479 kB ExceedsBaseline     432 bytes
PositioningContainer 112.301 kB ExceedsBaseline     432 bytes
PersonaPresence 105.251 kB ExceedsBaseline     432 bytes
PersonaCoin 158.64 kB ExceedsBaseline     432 bytes
Persona 158.568 kB ExceedsBaseline     432 bytes
Overlay 91.302 kB ExceedsBaseline     432 bytes
Modal 112.067 kB ExceedsBaseline     432 bytes
MarqueeSelection 111.388 kB ExceedsBaseline     432 bytes
List 75.808 kB ExceedsBaseline     432 bytes
Link 97.83 kB ExceedsBaseline     432 bytes
Tooltip 129.269 kB ExceedsBaseline     432 bytes
Label 91.262 kB ExceedsBaseline     432 bytes
KeytipData 68.65 kB ExceedsBaseline     432 bytes
Image 95.552 kB ExceedsBaseline     432 bytes
ActivityItem 164.888 kB ExceedsBaseline     432 bytes

ExceedsTolerance  Exceeds Tolerance     ExceedsBaseline  Exceeds Baseline     BelowBaseline  Below Baseline     1 kB = 1000 bytes


element = isElementTabbable(element)
? element
: getNextElement(this._root.current as HTMLElement, element, true) || getPreviousElement(this._root.current as HTMLElement, element)!;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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...

@dzearing dzearing requested review from a team, joschect and micahgodbolt as code owners January 30, 2019 01:20
…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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

element should already be an HTMLElement

Copy link
Copy Markdown
Member

@ecraig12345 ecraig12345 Jan 30, 2019

Choose a reason for hiding this comment

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

It's possibly null. this._root.current! would more clearly communicate that.

}
};

private _setParkedFocus(isParked: boolean): void {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is parked focus just when focus is at the root/highest thing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will add comments.

@dzearing dzearing merged commit 468af6a into microsoft:master Jan 31, 2019
@dzearing dzearing deleted the focuszone branch January 31, 2019 19:28
@msft-github-bot
Copy link
Copy Markdown
Contributor

🎉@uifabric/utilities@v6.29.0 has been released which incorporates this pull request.:tada:

Handy links:

@msft-github-bot
Copy link
Copy Markdown
Contributor

🎉office-ui-fabric-react@v6.132.0 has been released which incorporates this pull request.:tada:

Handy links:

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.

FocusZone: restore focus when focused item is removed.

6 participants