quill icon indicating copy to clipboard operation
quill copied to clipboard

Link tooltip cut off by edge of editor

Open brettimus opened this issue 11 years ago • 45 comments

Chrome 42 on a Mac

To reproduce, go to to quill's homepage, and try to add a link to the left-most word on a line. For me, the link tooltip becomes partially obscured. Screenshot attached.

image

brettimus avatar May 07 '15 16:05 brettimus

I've noticed this as well for all the tooltips. It should be detecting the edge of the editor. Also, something I've been wondering about for awhile @jhchen, why do the tooltips use a high negative number for the left css property to hide them instead of visibility: hidden or display: none? Ideally, I'd think you'd just want to add a class like ql-active to the tooltip and have the correct display value in the CSS files.

willrowe avatar May 07 '15 16:05 willrowe

Think I found (part of) the issue. Right now, I'm fiddling with this line

Presently, it is adding half of the referenceBounds.width and subtracting half of the tooltipBounds.width from an offset to calculate the left attribute of the tooltip.

I made a change to subtract half of the referenceBounds.width and add half of the tooltipBounds.width, and the tooltip no longer gets cut-off, but its placement seems slightly off.

I'm going to keep fiddling, but if anyone has insights please pass them along!

brettimus avatar May 07 '15 18:05 brettimus

That code seems to be correct, there just needs to be an extra check to make sure that the value that's calculated is not less than 0, if so it should set it to 0.

willrowe avatar May 07 '15 18:05 willrowe

Touché! Trying that now.

brettimus avatar May 07 '15 18:05 brettimus

Works, but the issue then becomes that (on smaller screens) the Change Remove and Done links get cut off on the right. :grimacing:

brettimus avatar May 07 '15 18:05 brettimus

It probably needs to wrap depending on it's width then. @jhchen will need to weigh in on how he'd like to handle that.

willrowe avatar May 07 '15 18:05 willrowe

Yeah I fixed by getting rid of the white-space: nowrap; style on the .ql-tooltip class. But I'm assuming that's there for a reason sooooo. Yeah.

Thanks for your comments @willrowe!

brettimus avatar May 07 '15 18:05 brettimus

The initial implementation of the tooltip was when Quill was still in an iframe so it necessarily had to be confined within the editor so there was logic that would place the tooltip to avoid being cut off (in the vertical direction as well).

Now there's not necessarily that motivation with iframes removed which is why https://github.com/quilljs/quill/commit/04c7c277bce2e879c32aa2cdc2df60f4bd82bd5c landed but it looks like just a high z-index on the tooltip is not sufficient--the overflow-y on .ql-container needs to be removed as well to fix this particular issue. However this is an important rule to allow scrolling in the editor so I'm not sure right now what the best solution is but thought I'd add some context.

@willrowe The high negative margin is because browsers do not correctly report dimensions when an element is hidden. I'm can't remember if/why visibility was passed over as well though.

jhchen avatar May 07 '15 19:05 jhchen

@jhchen - How would you feel about:

  • Ensuring the left attribute is non-negative
  • Removing white-space: nowrap; from the CSS on ql-tooltip (replacing with white-space: normal?)

Alternatively, it'd be possible to avoid the overflow issue outright by using fixed instead of absolute positioning for the tooltip(s)... but that would in turn require redoing the position calculations.

/shrug

brettimus avatar May 07 '15 22:05 brettimus

The tooltip placement has been reverted to be within the editor https://github.com/quilljs/quill/commit/fd099bb40db8557570da544d5976e2f250bba463.

jhchen avatar May 08 '15 23:05 jhchen

Guys, somehow it is not working now again. Using react-quill (quill is the latest version).

ArtemBernatskyy avatar May 07 '19 03:05 ArtemBernatskyy

Seems to be working when using Snow theme, but Bubble is definitely broken.

  • Go to: https://quilljs.com/docs/themes/
  • Scroll to the Bubble sample
  • Enter some text on the first line
  • Turn the first word into a link
  • Hover the link. The bubble tooltip is cut off by the edges of the editor.

I tried playing around with the CSS, I couldn't get it to work.

Carl012 avatar May 14 '19 16:05 Carl012

Anyone have a css fix for the url popup on bubble theme? Confirmed the issue is visible on https://quilljs.com/docs/themes/ as @Carl012 describes. Just paste a url into top line then hover over it to see issue.

Edit - this looks to fix it. .ql-editor { overflow: visible; }

petemcwilliams avatar Oct 15 '19 08:10 petemcwilliams

I found a solution for my situation: when create the configuration object, set property 'bounds' with the selector of quill container.

Example:

const SELECTOR_CONTAINER = '#quill-container-2';
const DEFAULT_CONFIG = {
        theme: 'bubble',
        bounds: SELECTOR_CONTAINER
};

new Quill(SELECTOR_CONTAINER, DEFAULT_CONFIG);

FenoRC avatar Feb 11 '20 18:02 FenoRC

This positions the video tooltip at a fixed position

$(document).ready(
   function() {
         $('.ql-video').click(function() {
            $('.ql-tooltip').css("left", "0");
            $('.ql-tooltip').css("margin-left", "10px");
            $('.ql-tooltip').css("top", "0");
            $('.ql-tooltip').css("margin-top", "2px");
         }
      );
   }
);

cmd05 avatar Jul 11 '20 19:07 cmd05

I found a solution for my situation: when create the configuration object, set property 'bounds' with the selector of quill container.

Example:

const SELECTOR_CONTAINER = '#quill-container-2';
const DEFAULT_CONFIG = {
        theme: 'bubble',
        bounds: SELECTOR_CONTAINER
};

new Quill(SELECTOR_CONTAINER, DEFAULT_CONFIG);

This is what worked for me. Thank you!!

TheAustinG avatar Jul 15 '20 18:07 TheAustinG

If anyone is using angular, then you can try the following in your css or scss file ;)

::ng-deep.ql-tooltip {
    left: unset !important;
}

brijeshlakkad avatar Aug 08 '20 18:08 brijeshlakkad

This works for me

.ql-tooltip {
  left: 0 !important;
}

thangnq1001 avatar Aug 21 '20 07:08 thangnq1001

Had the same problem. @petemcwilliams 's solution worked for me

robinjhuang avatar Oct 10 '20 22:10 robinjhuang

@FenoRC's solution also work for me. As if bounds not defined, tooltips positioned using document. I could also use this solution for react implementation ReactQuill like:

<div data-text-editor="name">
     <ReactQuill
            theme="snow"
            value={formContext[name]}
            onChange={handleTextChange}
            bounds={`[data-text-editor="name"]`}
          />
</div>

emre-haufe-canei avatar Mar 30 '21 17:03 emre-haufe-canei