Skip to content

[Pickers] Add async debounce option to BasePicker#4163

Merged
dzearing merged 1 commit intomicrosoft:masterfrom
machineloop:basepicker-async-debounce
Mar 6, 2018
Merged

[Pickers] Add async debounce option to BasePicker#4163
dzearing merged 1 commit intomicrosoft:masterfrom
machineloop:basepicker-async-debounce

Conversation

@machineloop
Copy link
Copy Markdown
Contributor

Pull request checklist

  • Include a change request file using $ npm run change

Description of changes

Add mechanism to debounce searching in pickers

Add resolveDelay to allow consumer to add a delay on calling resolveSuggestions (to not burden services and not waste cycles on throw away searches)

Focus areas to test

PeoplePicker

@machineloop machineloop requested a review from joschect as a code owner March 2, 2018 17:46
@machineloop
Copy link
Copy Markdown
Contributor Author

@antonlabunets Debounce for PeoplePicker component needed for Yammer webpart in Sharepoint, please review?

/**
* A callback for when the input has been changed
*/
onInputChanged?: (filter: string) => 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.

I'm very hesitant to add another onInputChange, there is already one that is used which is passed down to the autofill. Is there anyway that could be used instead?

Copy link
Copy Markdown
Contributor Author

@machineloop machineloop Mar 2, 2018

Choose a reason for hiding this comment

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

Yeah, I can remove this, not critical to our needs, just what I thought would be a nice-to-have...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed, thanks!

@machineloop machineloop force-pushed the basepicker-async-debounce branch from 3f0a09a to e67cf62 Compare March 2, 2018 22:42
@machineloop
Copy link
Copy Markdown
Contributor Author

@joschect Thanks for the review, ready for a second pass. I'm happy to polish up anything else that might need work...

* e.g. If a second input change happens within the resolveDelay time, the timer will start over.
* Only until after the timer completes will onResolveSuggestions be called.
*/
resolveDelay?: number;
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 there a default? Should it default to something? Will it get treated as no delay without it?

Copy link
Copy Markdown
Contributor Author

@machineloop machineloop Mar 3, 2018

Choose a reason for hiding this comment

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

Good question, right now no default is set so that if the resolveDelay prop isn't passed in, there's no delay but still passes through debounced function.

I felt an opt-in was safer than setting default, but if you feel this should be a default behavior, we can add one. The delay I'm using in the examples is 300 ms

Copy link
Copy Markdown
Contributor

@joschect joschect left a comment

Choose a reason for hiding this comment

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

Approved with one more question/suggestion

@dzearing dzearing merged commit 4368015 into microsoft:master Mar 6, 2018
@machineloop machineloop deleted the basepicker-async-debounce branch March 6, 2018 14:08
Markionium added a commit to Markionium/office-ui-fabric-react that referenced this pull request Mar 6, 2018
* master:
  Applying package updates.
  Polyfill react create ref (microsoft#4182)
  [Pickers] Add async debounce option to BasePicker (microsoft#4163)
  Facepile conditionally rendering aria-describedby (microsoft#4183)
  Applying package updates.
  Addressing Issue microsoft#4174 - 5.59.0 crashing in <ImageBase> (microsoft#4185)
  Website fix: Remove PureComponent (microsoft#4186)
  Add Keytip and KeytipLayer to experiments export (microsoft#4184)
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 31, 2019
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.

3 participants