Skip to content
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

Link tooltip cut off by edge of editor #360

Closed
brettimus opened this issue May 7, 2015 · 41 comments
Closed

Link tooltip cut off by edge of editor #360

brettimus opened this issue May 7, 2015 · 41 comments

Comments

@brettimus
Copy link

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

@willrowe
Copy link
Contributor

willrowe commented May 7, 2015

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.

@brettimus
Copy link
Author

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!

@willrowe
Copy link
Contributor

willrowe commented May 7, 2015

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.

@brettimus
Copy link
Author

Touché! Trying that now.

@brettimus
Copy link
Author

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

@willrowe
Copy link
Contributor

willrowe commented May 7, 2015

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.

@brettimus
Copy link
Author

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!

@jhchen
Copy link
Member

jhchen commented May 7, 2015

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 04c7c27 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.

@brettimus
Copy link
Author

@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

@jhchen
Copy link
Member

jhchen commented May 8, 2015

The tooltip placement has been reverted to be within the editor fd099bb.

@ArtemBernatskyy
Copy link

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

@Carl012
Copy link

Carl012 commented May 14, 2019

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.

@petemcwilliams
Copy link

petemcwilliams commented Oct 15, 2019

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;
}

@FenoRC
Copy link

FenoRC commented Feb 11, 2020

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);

@cmd05
Copy link

cmd05 commented Jul 11, 2020

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");
         }
      );
   }
);

@TheAustinG
Copy link

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!!

@Brijeshlakkad
Copy link

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

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

@thangnq1001
Copy link

This works for me

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

@robinjhuang
Copy link

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

@emre-haufe-canei
Copy link

emre-haufe-canei commented Mar 30, 2021

@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>

@ashishmishra-spec
Copy link

You can also add this inside quill editor section script

$("a").click(function() { $(".ql-tooltip").css('left', 0+'px'); $(".ql-editing").css('left', 0+'px'); });

@nomad-vagabond
Copy link

Just add a single line to the position method of the quill Tooltip class
left = Math.max(left, 0)
to patch negative value. This way tooltip's position will be still floating but set to zero in case it is out of the left bound.

    value: function position(reference) {
      var left = reference.left + reference.width / 2 - this.root.offsetWidth / 2;
      left = Math.max(left, 0)
      // root.scrollTop should be 0 if scrollContainer !== root

@tuananhlai
Copy link

@emre-haufe-canei 's solution works for me.

@lakindu2002
Copy link

i am facing this issue still. anyone figured out how to solve it? none of the solutions above work for me
image

@rhdn520
Copy link

rhdn520 commented Aug 7, 2022

If you are using angular, try using ElementRef to set bounds property

<div #editorContainer>
        <quill-editor [bounds]="editorContainer"></quill-editor>
</div>

then in component

@ViewChild('editorContainer') editorContainer?:ElementRef;

@aliakbarazizi
Copy link

I used this css since I want to tooltip becaome realtive to selected text
transform: translateY(10px) translateX(50%);

@Ixiondbz
Copy link

Ixiondbz commented May 22, 2023

I used this css since I want to tooltip becaome realtive to selected text transform: translateY(10px) translateX(50%);

This will still cut off the right portion of the tooltip if you try to place it on the far right side(not the furthest side though).

@aliakbarazizi
Copy link

I used this css since I want to tooltip becaome realtive to selected text transform: translateY(10px) translateX(50%);

This will still cut off the right portion of the tooltip if you try to place it on the far right side(not the furthest side though).

you can change number to put it where exactly you want, the point is if you use transform it will be related to previose location

@jisaar2
Copy link

jisaar2 commented Jul 19, 2023

Just add a single line to the position method of the quill Tooltip class left = Math.max(left, 0) to patch negative value. This way tooltip's position will be still floating but set to zero in case it is out of the left bound.

    value: function position(reference) {
      var left = reference.left + reference.width / 2 - this.root.offsetWidth / 2;
      left = Math.max(left, 0)
      // root.scrollTop should be 0 if scrollContainer !== root

Here is a way to do this by using SCSS only if you are still running into this issue within a p-editor Angular component:

::ng-deep div[style*="left: -"] {
  &.ql-tooltip {
    left: unset !important;
  }
}

@nikkhah63
Copy link

I add style overflow: "visible" to .ql-container and it fixed for me.

@JelynValcorza
Copy link

JelynValcorza commented Sep 5, 2023

Screenshot 2023-09-05 145517

How to resolve this ? It ain't working all your recommend resolution ideas

@trend-alan-bie
Copy link

@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>

works for me

@JelynValcorza
Copy link

@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>

works for me

I'm using Modal / Dialog, it still cut off the edge of the Link pop-up

@trend-alan-bie
Copy link

@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>

works for me

I'm using Modal / Dialog, it still cut off the edge of the Link pop-up

I'm using it inside a drawer too, but it works perfectly

@JelynValcorza
Copy link

@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>

works for me

I'm using Modal / Dialog, it still cut off the edge of the Link pop-up

I'm using it inside a drawer too, but it works perfectly

How? Can you share ?

@JelynValcorza
Copy link

image
It looks like this..

@trend-alan-bie
Copy link

Just the same with the demo:

    <Box height={height} data-text-editor="editor">
      <CustomToolbar />
      <ReactQuill
        readOnly={previewMode}
        ref={editorRef}
        theme="snow"
        modules={modules}
        formats={formats}
        defaultValue={value}
        value={value}
        onChange={onChange}
        bounds={'[data-text-editor="editor"]'}
      />
    </Box>

@ezhupa99
Copy link

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

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

Thanks, it worked for me

@SurajanShrestha
Copy link

@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 This worked for me ✅. Thank you for posting this solution 🚀.

Note 💡: We can also write a class instead of data-text-editor and it will still work.

Code 👇

<div className="my-editor-container">
     <ReactQuill
          theme="snow"
          value={formContext[name]}
          onChange={handleTextChange}
          bounds={`.my-editor-container`}
     />
</div>

@trend-alan-bie
Copy link

How? Can you share ?

If somebody still facing this issue, ensure that the selector or DOM element for the 'bounds' prop is unique, This means the editorName should be passed as a prop. I experienced a similar issue when rendering the Quill editor twice as a component but using the same 'bounds'.

    <Box
      height={height} minHeight={minHeight} onFocus={onFocus}
      className={error ? 'error' : ''} data-text-editor={editorName}
    >
      {!previewMode && <CustomToolbar toolbar={toolbar} /> }
      <ReactQuill
        readOnly={previewMode}
        ref={editorRef}
        theme="snow"
        modules={modules}
        formats={formats}
        defaultValue={value}
        value={value}
        onChange={onChange}
        bounds={`[data-text-editor=${editorName}]`}
      />
    </Box>

@ashvin777
Copy link

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 worked for me. One thing to notice here, that the bounds container element needs to be mounted before it will render the Quill container. So you should prefer the ref the container from its parent component instead of passing the parent from the same component. That might solve some of the issues you guys are facing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests