Skip to content

Commit

Permalink
Merge pull request #14560 from ckeditor/ck/5465-sticky-panel-overflow…
Browse files Browse the repository at this point in the history
…ed-ancestors

Fix (ui): Fixed the sticky panel behavior in overflowing containers. Closes #5465.
  • Loading branch information
oleq authored Jul 12, 2023
2 parents d361390 + 4f9ce3c commit 73a0b8d
Show file tree
Hide file tree
Showing 7 changed files with 906 additions and 195 deletions.
97 changes: 97 additions & 0 deletions packages/ckeditor5-editor-classic/tests/manual/stickypanel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<head>
<style>
body {
max-width: 800px;
margin: 20px auto;
padding: 1000px 50px;
min-height: 5000px;
}

.scrollable {
padding: 80px;
border: 1px solid #ccc;
overflow: scroll;
height: 250px;
margin-top: 30px;
margin-bottom: 200px;
box-sizing: border-box;
}

.ck.ck-editor {
margin-bottom: 150px !important;
}

.viewport-offset {
position: fixed;
top: 0;
width: 500px;
left: 50%;
transform: translateX(-50%);
background: green;
height: 50px;
color: #fff;
opacity: .6;
z-index: 99999;
}
</style>
</head>

<div class="viewport-offset">Viewport offset</div>

<div class="scrollable outer">
<div class="scrollable inner">
<div id="editor">
<h2>Heading 1</h2>
<p>Paragraph</p>
<p><strong>Bold</strong> <i>Italic</i> <a href="https://ckeditor.com">Link</a></p>
<ul>
<li>UL List item 1</li>
<li>UL List item 2</li>
</ul>
<ol>
<li>OL List item 1</li>
<li>OL List item 2</li>
</ol>
<figure class="image image-style-side">
<img alt="bar" src="sample.jpg">
<figcaption>Caption</figcaption>
</figure>
<blockquote>
<p>Quote</p>
<ul>
<li>Quoted UL List item 1</li>
<li>Quoted UL List item 2</li>
</ul>
<p>Quote</p>
</blockquote>
</div>
</div>
</div>

<h3>Unrelated scrollable container for testing.</h3>
<div class="scrollable">

<h2>Heading 1</h2>
<p>Paragraph</p>
<p><strong>Bold</strong> <i>Italic</i> <a href="https://ckeditor.com">Link</a></p>
<ul>
<li>UL List item 1</li>
<li>UL List item 2</li>
</ul>
<ol>
<li>OL List item 1</li>
<li>OL List item 2</li>
</ol>
<figure class="image image-style-side">
<img alt="bar" src="sample.jpg">
<figcaption>Caption</figcaption>
</figure>
<blockquote>
<p>Quote</p>
<ul>
<li>Quoted UL List item 1</li>
<li>Quoted UL List item 2</li>
</ul>
<p>Quote</p>
</blockquote>
</div>
54 changes: 54 additions & 0 deletions packages/ckeditor5-editor-classic/tests/manual/stickypanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* globals console, window, document */

import ClassicEditor from '../../src/classiceditor';

import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';

ClassicEditor
.create( document.querySelector( '#editor' ), {
plugins: [ ArticlePluginSet ],
toolbar: [
'heading',
'|',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'|',
'outdent',
'indent',
'|',
'blockQuote',
'insertTable',
'mediaEmbed',
'undo',
'redo'
],
image: {
toolbar: [ 'imageStyle:inline', 'imageStyle:block', 'imageStyle:side', '|', 'imageTextAlternative' ]
},
table: {
contentToolbar: [
'tableColumn',
'tableRow',
'mergeTableCells'
]
},
ui: {
viewportOffset: {
top: 50
}
}
} )
.then( editor => {
window.editor = editor;
} )
.catch( err => {
console.error( err.stack );
} );
12 changes: 12 additions & 0 deletions packages/ckeditor5-editor-classic/tests/manual/stickypanel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Sticky panel

Verify the behavior of the sticky panel inside the overflowing (scrollable) containers.
Best to run with `--debug=stickypanel` flag.

Tests:
* Panel should stick only when it's active.
* Panel should not change its state when scrolling the element that isn't its ancestor (drawn rects will disappear though).
* Sticky toolbar inside the inner container.
* Sticking the toolbar when scrolling the outer container.
* Top viewport offset should be taken into account when scrolling the window.
* Panel should stick to the bottom of the container when it's near end.
Loading

0 comments on commit 73a0b8d

Please sign in to comment.