question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inline mode in scrolling container, toolbar incorrectly positioned

See original GitHub issue

This seems to occur if the scroll container has been scrolled so that the top of the scroll container is above the top of the page, and neither the top or the bottom of the editor is visible.

The bug appears to be in the modern theme within the reposition function, moveRel in the panel handles positioning of the toolbar after the editor, but then moveBy is called which causes the toolbar to be moved beyond the bottom of the page.

Here is a simple repro (you’ll need to npm install tinymce), I did try to reproduce with tinymce fiddle but I couldn’t get it to work, possibly something related to how the layout for that page works.

<!DOCTYPE html>
<html>
	<head>
		<title>Hello, World!</title>
		<style type="text/css">
			#scroll-container {
				overflow-y: scroll;
				
				width: 70vw;
				height: 70vh;
				
				margin: 50px;
				border: 1px solid red;
			}
			
			#textInput {
				height: 150%;
				width: 90%;
				
				border: 1px solid green;
			}
		</style>
		<!-- TinyMCE version 4.8.3 -->
		<script src="node_modules/tinymce/tinymce.min.js"></script>
		<script>
		tinymce.init({
			selector: '#textInput',
			theme: "modern",
			skin: 'lightgray',
			inline: true
		});
		</script>
	</head>
	<body>
		<p>Red border = scroll container, green border = text area</p>
		<div id="scroll-container">
			<div id="textInput">
				<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
			</div>
		</div>
	</body>
</html>

I would expect that if the top and bottom of the editor are both off screen, the toolbar be shown either at the top or bottom of the visible portion, I’ve found that by changing the reposition function to the following in modern/theme.js, this functions correctly.

var reposition = function () {
      if (panel && panel.moveRel && panel.visible() && !panel._fixed) {
        var scrollContainer = editor.selection.getScrollContainer(), body = editor.getBody();
        var deltaX = 0, deltaY = 0;
        if (scrollContainer) {
          var bodyPos = DOM.getPos(body), scrollContainerPos = DOM.getPos(scrollContainer);
          deltaX = Math.max(0, scrollContainerPos.x - bodyPos.x);
          deltaY = Math.max(0, scrollContainerPos.y - bodyPos.y);
        }

        var rel =  editor.rtl ? [
          'tr-br',
          'br-tr'
        ] : [
          'tl-bl',
          'bl-tl',
          'tr-br'
        ];

        rel = panel.fixed(false).testMoveRel(body, rel);

        if (rel === 'bl-tl') {
          deltaY = 0;
        }

        panel.fixed(false).moveRel(body, rel).moveBy(deltaX, deltaY);
      }
};

I’ve seen this issue with tinymce 4.8.3 in Chrome 68 on Windows.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mattfordcommented, Sep 19, 2018

Thanks for the comment @villermen, I did have a look through but didn’t catch that that one was related

1reaction
villermencommented, Sep 18, 2018

Duplicate of #4153 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

CKEditor inline toolbar position incorrect within scrolling div
Scroll the scrollbar for the div. Click on the element again. The toolbar shows in it's original position.
Read more >
Toolbar is incorrectly positioned in inline mode when inside scroll ...
What is the current behavior? Describe the bug. When using inline mode in a scroll container, the toolbar is not repositioned when the...
Read more >
TinyMCE inline mode with iframe - Stack Overflow
I have to use inline mode because only this mode supports fixed_toolbar_container . The toolbar has to be placed on top of page....
Read more >
Safari Technology Preview Release Notes - Apple Developer
Fixed inline box decoration position when the content box is vertically shifted with ... Fixed a crash clicking on Safari App Extension toolbar...
Read more >
overflow-x - CSS: Cascading Style Sheets - MDN Web Docs
The difference between clip and hidden is that the clip keyword also forbids all scrolling, including programmatic scrolling. The box is not a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found