-
-
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
Optimized initial toolbar render with toolbar grouping enabled #7656
Conversation
Removed a leftover.
…n would throw an exception. Closes #7655.
@@ -302,7 +302,7 @@ export default class ToolbarView extends View { | |||
console.warn( attachLinkToDocumentation( | |||
'toolbarview-item-unavailable: The requested toolbar item is unavailable.' ), { name } ); | |||
} | |||
} ); | |||
} ).filter( item => item !== undefined ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any test for this one? Why is it needed anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case factory has no matching button then an undefined is returned (from the callback above). It happens if you misspell button name in the configuration.
There's at least one existing test that will fail if it's not handled correctly:
ckeditor5/packages/ckeditor5-ui/tests/toolbar/toolbarview.js
Lines 411 to 426 in e2befc8
it( 'warns if there is no such component in the factory', () => { | |
const items = view.items; | |
const consoleWarnStub = sinon.stub( console, 'warn' ); | |
view.fillFromConfig( [ 'foo', 'bar', 'baz' ], factory ); | |
expect( items ).to.have.length( 2 ); | |
expect( items.get( 0 ).name ).to.equal( 'foo' ); | |
expect( items.get( 1 ).name ).to.equal( 'bar' ); | |
sinon.assert.calledOnce( consoleWarnStub ); | |
sinon.assert.calledWithExactly( consoleWarnStub, | |
sinon.match( /^toolbarview-item-unavailable/ ), | |
{ name: 'baz' } | |
); | |
} ); |
Co-authored-by: Aleksander Nowodzinski <a.nowodzinski@cksource.com>
Suggested merge commit message (convention)
Other (ui): Improved toolbar rendering time when multiple items are added or removed at once (e.g. during editor initialization). Closes #6194.
Fix (ui): Removing the first hidden toolbar button will no longer throw an exception. Closes #7655.
Additional information
While working on it I spotted #7655 and decided to fix it while porting old listeners.