Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "ContextualMenu: Update mousemove to only do anything if there is not another pending mouse enter/move/leave to improve the snappiness of the updates",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,9 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext

const targetElement = ev.currentTarget as HTMLElement;

if (!this._isScrollIdle || targetElement === this._targetWindow.document.activeElement as HTMLElement) {
if (!this._isScrollIdle ||
this._enterTimerId !== undefined ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

this._enterTimerId !== undefined [](start = 6, length = 32)

You actually do not need to do this. The following line of code will have the same affect and save you a few characters.

this._enterTimerId ||

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While it shouldn't be zero if it is a valid id, I couldn't find anything that technically says zero is not a valid return value. I don't want to make any assumptions which might make this code more brittle

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK sure. Your choice. I am certain it cannot be Zero. I know this because I have written such code more than once and never faced issues. That code has run for many years now.

https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
he returned timeoutID is a positive integer value which identifies the timer created by the call to setTimeout();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to IEEE 754-2008 zero can be signed and is positive by default (and can sometimes be negative), that being said it doesn't make sense to risk it

targetElement === this._targetWindow.document.activeElement as HTMLElement) {
return;
}

Expand Down Expand Up @@ -858,11 +860,13 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext
const splitButtonContainer = this._splitButtonContainers.get(item.key);
this._onItemSubMenuExpand(item,
((item.split && splitButtonContainer) ? splitButtonContainer : targetElement) as HTMLElement);
this._enterTimerId = undefined;
}, this._navigationIdleDelay);
} else {
this._enterTimerId = this._async.setTimeout(() => {
this._onSubMenuDismiss(ev);
targetElement.focus();
this._enterTimerId = undefined;
}, timeoutDuration);
}
}
Expand Down