-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add debounce mechanism to opening the mention panel #4619
Comments
Feed function function getFeed( feedText ) {
return new Promise( resolve => {
setTimeout( () => {
const itemsToDisplay = [
{ id: '1', name: 'Barney Stinson', username: 'swarley' },
{ id: '2', name: 'Lily Aldrin', username: 'lilypad' },
{ id: '3', name: 'Marshall Eriksen', username: 'marshmallow' },
{ id: '4', name: 'Robin Scherbatsky', username: 'rsparkles' },
{ id: '5', name: 'Ted Mosby', username: 'tdog' }
].filter( item => {
const searchString = feedText.toLowerCase();
return item.name.toLowerCase().includes( searchString ) || item.username.toLowerCase().includes( searchString );
} )
resolve( itemsToDisplay );
}, 5000 );
} );
} |
A feed with a random response time and no order guarantee is even more red: function getFeed( feedText ) {
return new Promise( resolve => {
const timeout = Math.floor( Math.random() * ( 3000 - 1000 ) + 1000 );
console.log( 'starting timeout', timeout, 'ms' );
setTimeout( () => {
const itemsToDisplay = [
{ id: '1', name: 'Barney Stinson', username: 'swarley' },
{ id: '2', name: 'Lily Aldrin', username: 'lilypad' },
{ id: '3', name: 'Marshall Eriksen', username: 'marshmallow' },
{ id: '4', name: 'Robin Scherbatsky', username: 'rsparkles' },
{ id: '5', name: 'Ted Mosby', username: 'tdog' }
].filter( item => {
const searchString = feedText.toLowerCase();
return item.name.toLowerCase().includes( searchString ) || item.username.toLowerCase().includes( searchString );
} )
console.log( 'ending timeout', timeout );
resolve( itemsToDisplay );
}, timeout );
} );
} |
We should test this with real implementations of client-server communication. We could build a super simpler server in Node.js which would simulate querying some DBs (setTimeout with a random delay should do). Based on that we should develop a reference implementation of a mention's feed function which communicates with that server and check what we need to change in the mention plugin implementation to make it relatively easy to handle potential issues (stacking requests, wrong response order, etc.) |
I checked the
The cache control box is fine. If it could be easily developed I'd actually ping/fetch a dummy response from dev-server to make sure it is up and running. If not display a clear big information that the server is required and how to do that (basically the information you included on a left hand side). If you're concerned about hitting worst response time, you could allow for a get parameter like From other unrelated things: only now I see flickering in mentions sample, so only here I'm able to reproduce ckeditor/ckeditor5-mention#29. |
We support the asynchronous feeds but when the reading items from the API takes noticable time it may happen that user will type faster then the mention UI is showing resulting in
showingupdating the list in the the UI multiple times.The text was updated successfully, but these errors were encountered: