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

Colorpicker - automatic positioning #213

Open
a4DEVP opened this issue Nov 28, 2019 · 4 comments
Open

Colorpicker - automatic positioning #213

a4DEVP opened this issue Nov 28, 2019 · 4 comments
Labels

Comments

@a4DEVP
Copy link

a4DEVP commented Nov 28, 2019

The color picker should open upward when there's not enough space at the bottom and vice-versa.
Is this possible?
The [cpPosition] - auto doesn't work and I am using the latest version of the plugin.
Any help will be appreciated.

@DebuggerAK
Copy link
Contributor

Try to use cpUseRootViewContainer = true. Is it a mobile view problem?

@sujeetjaiswara
Copy link

Same issue here

@tmtron
Copy link

tmtron commented Sep 11, 2021

on small (e.g. mobile) screens it would even be better to open it as a modal dialog over the input field (i.e. to hide it) - otherwise we easily get into a situation where the OK button is off screen

e.g. in the current demo, when we switch to mobile mode and click an input near the bottom, it will open the color picker to the right-botom:

image

here's my workaround, at the end of the setDialogPosition function:

          /**
           * we want to make sure, that the bottom/right is always visible: i.e. to access the OK button
           */
          const dialogBounds = this.dialogElement.nativeElement.getBoundingClientRect();
          const bottom =  this.top + dialogBounds.height;
          if (bottom > window.innerHeight) {
            this.top = window.innerHeight - dialogBounds.height;
          }
          const right =  this.left + dialogBounds.width;
          if (right > window.innerWidth) {
            this.left = window.innerWidth - dialogBounds.width;
          }

@tmtron
Copy link

tmtron commented Jun 7, 2023

Fix #329 works for me, but only the first time that I open the dialog.
Unfortunately I cannot reproduce this in the example app. I guess that i is related to change detection (onPush) or the fact, that we show the picker in a dialog?

When debugging I can see that this code:

const dialogBounds = this.dialogElement.nativeElement.getBoundingClientRect();

returns only 0 (for top, etc.).

I think that the reason for this is that the dialog is not visible yet.
I patched this code:

this.hidden = false;
this.setDialogPosition();
this.cdRef.detectChanges();

to also call this.cdRef.detectChanges(); before this.setDialogPosition();.
Then the issue is fixed for me.

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

No branches or pull requests

5 participants