Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #525 from ckeditor/i/5608
Browse files Browse the repository at this point in the history
Internal: Automatic toolbar grouping dropdown should not be auto-positioned. Closes ckeditor/ckeditor5#5608.
  • Loading branch information
Reinmar authored Oct 17, 2019
2 parents 67a5a81 + 16d20a9 commit 9b40ebd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/toolbar/toolbarview.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,11 @@ class DynamicGrouping {
const dropdown = createDropdown( locale );

dropdown.class = 'ck-toolbar__grouped-dropdown';

// Make sure the dropdown never sticks out to the left/right. It should be under the main toolbar.
// (https://github.com/ckeditor/ckeditor5/issues/5608)
dropdown.panelPosition = locale.uiLanguageDirection === 'ltr' ? 'sw' : 'se';

addToolbarToDropdown( dropdown, [] );

dropdown.buttonView.set( {
Expand Down
7 changes: 7 additions & 0 deletions tests/manual/toolbar/grouping.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ <h2>Editor with RTL UI</h2>
<div id="editor-rtl">
<p>Editor content</p>
</div>

<style>
.ck.ck-editor {
margin-left: 200px;
margin-right: 200px;
}
</style>
1 change: 1 addition & 0 deletions tests/manual/toolbar/grouping.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
2. Refresh the test.
3. The toolbar should looks the same. Make sure none of toolbar items wrapped or overflow.
4. The dropdown button should be displayed at the end of the toolbar, allowing to access grouped features.
* The drop–down should be displayed **under** the main toolbar.
5. Grouped items toolbar should never start or end with a separator, even if one was in the main toolbar space.
6. Other separators (between items) should be preserved.

Expand Down
22 changes: 22 additions & 0 deletions tests/toolbar/toolbarview.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,28 @@ describe( 'ToolbarView', () => {
expect( groupedItemsDropdown.toolbarView.items.map( i => i ) )
.to.have.ordered.members( groupedItems.map( i => i ) );
} );

// https://github.com/ckeditor/ckeditor5/issues/5608
it( 'has the proper position depending on the UI language direction (LTR UI)', () => {
const locale = new Locale( { uiLanguage: 'en' } );
const view = new ToolbarView( locale, { shouldGroupWhenFull: true } );
view.render();

expect( view._behavior.groupedItemsDropdown.panelPosition ).to.equal( 'sw' );

view.destroy();
} );

// https://github.com/ckeditor/ckeditor5/issues/5608
it( 'has the proper position depending on the UI language direction (RTL UI)', () => {
const locale = new Locale( { uiLanguage: 'ar' } );
const view = new ToolbarView( locale, { shouldGroupWhenFull: true } );
view.render();

expect( view._behavior.groupedItemsDropdown.panelPosition ).to.equal( 'se' );

view.destroy();
} );
} );

describe( 'item overflow checking logic', () => {
Expand Down

0 comments on commit 9b40ebd

Please sign in to comment.