Primefaces calendar does not readjust its position on window rotation - css

I am struggling with a primefaces calendar problem on a webpage rendered on a mobile device (tablet). It seems that the css values calculated by primefaces to show the popup calendar are not recalculated on window rotation (you need to click on it again to recalculate).
Here is an example:
I have my webpage displayed in portrait mode. I clicked the calendar icon and the position of the popup is good:
(notice the css with left: 719.406px, calculated by primefaces). Everything OK so far.
Now I rotate to landscape mode:
Notice that the popup is no longer near the calendar icon. Also, the css states that, by having the same left value.
In order to get it correct, I need to click anywhere on the screen to close the pop up, then click again on the calendar icon:
The position is now good, with a different and correct value of left: 1061.91px.
How can I make primefaces automatically readjust the css without having to double click each time?
The solution found for me so far was to add a custom value for the right alignment with the screen and override the left one:
.ui-datepicker.ui-widget.ui-widget-content {
left: auto !important;
right: 10px;
}
But the above solution is very specific for this screen and luckily because I always have the calendar button in the right part of the screen, so I can always assume that 10 pixels from the right will look ok.
I also noticed that ui-datepicker-div is a child of body element, so I cannot link it with the button with css.
Any ideas/help of a general solution will be highly appreciated.
Primefaces version: 6.2

This problem is fixed with Primefaces 7.0.RC3.
It was released a week ago.
https://mvnrepository.com/artifact/org.primefaces/primefaces/7.0.RC3

Related

How to get rid of useless scrollbars in a material dialog when a radio-group is used?

This Stackblitz example opens a simple dialog which contains a radio group in the mat-dialog-content div.
You can see that the dialog-content shows an ugly scrollbar:
This does not happen when other components are used: e.g. input, etc.
Using chrome dev-tools, I can see that the mat-radio-buttons have a height of 20px:
but the mat-radio-group only has a height of 17px:
Is this a bug in angular material components (the example uses version 12.0.4), or is there a simple workaround/css that we can use to get rid of the scrollbar?
I've tried explicitly setting the height on the mat-radio-group, but this has no effect.
Notes:
in production we do of course have many dialogs and some of them are large and need the scrollbars
we need an application wide solution/workaround
simply hiding the scrollbars is not okay: it must remain auto so that the dialog can react to size changes (e.g. user rotates device, some items are shown/hidden dynamically, etc.
For now we came up with a workaround that fixes the issue in all our 30+ dialogs.
The nice thing is that we can apply it in one place, in styles.scss:
.mat-dialog-content {
padding-bottom: 10px !important;
}
We just add a padding to the bottom of the dialog content area and then scrollbars: auto works as expected in all our dialogs (small and large). i.e. when you make the browser window larger/smaller, the scrollbar is automatically shown/hidden.
And it also works when there are multiple mat-radio-groups in one dialog.
The additional padding between the content and bottom dialog-actions is acceptable for our ui.
Stackblitz example with workaround
The reason this happens is due to the ripple effect on the radio button - which takes up additional space and causes the scrollbar to show. See https://github.com/angular/components/issues/20344
There are a number of ways to resolve this, such as using padding or margins on the components or on the dialog content itself like you did. The important thing is that there is enough space added to accommodate the ripple.

Ionic-Angular can't get list to scroll properly

I've been trying to programmatically scroll a list (accordion) in an Ionic-Angular app and I’ve been having no success at all.
I reproduced it in this stackblitz: https://stackblitz.com/edit/stack-overflow-ionic-scroll-problem?file=src/app/home/home.page.ts
When you click on an item, it expands and I want it to align to the top of the screen (with the title visible). In this example, I am using scrollIntoView() to get it to the top but it disappears behind the toolbar.
I've tried many things to get it to align properly (including setting a "scroll-margin-top" as suggested on many posts) but this hasn't worked for me.
Also, I can't seem to be able to use the scrollBy() or scrollTo() method... they do nothing at all.
Can anybody help me figure this out and get this precise example to work? Thanks in advance!
The problem is in the property [fullscreen]="true" of the <ion-content> tag.
The property fullscreen of ion-content, according to the ionic documentation...
If true, the content will scroll behind the headers and footers. This effect can easily be seen by setting the toolbar to transparent.
In ionic when you use the option fullscreen as in <ion-content [fullscreen]="true"> it adds the following style to the ion-content tag:
--offset-top: 56px;
The goal of the [fullscreen]="true" is to create the effect of the content scrolling behind the header.
As a side effect, part of the <ion-content> is hidden behind the <ion-header>.
Fullscreen property and scrollIntoView()
According to w3schools...
The scrollIntoView() method scrolls the specified element into the visible area of the browser window.
So, in your code, when you call scrollIntoView() of a group it is working exactly as expected. The screen is scrolled until the top o the group is into the visible area of the browser. The problem is that the <ion-header> is covering part of the top of this visible area.
Solution:
If you remove the [fullscreen]="true" of the <ion-content>tag the scroll will work as you expect.
But you will loose the effect created by the fullscreen property (content scrolling behing the header).
References
Fullscreen property of ion-content tag:
https://ionicframework.com/docs/api/content
ScrollIntoView:
https://www.w3schools.com/JSREF/met_element_scrollintoview.asp

Show embedded select box on overflow, out of popup container

I am having a popup page,in that page i have a select box, which i have applied jquery UI selectmenu. The problem is that the selectbox is in the bottom of the popup, and when it gets open, it get out of the popup limits.
My actual code (I cannot paste here my code for security reasons) has:
The z-index of of the select box is bigger compared to pop up container´s one, so its rendering on top of the pop up with no-issues.
The z-index for the select box is in relative with the pop up,not with the whole page,so the select box is hiding behind the pop-up when
the pop up height is less.
The desired behaviour is when popup height is less than needed to show all the select box. I need to show the select box without hiding.
If i did not apply jquery ui select menu, it´s working as expected.
Please find the below images for reference.
1.When having enoug popup size.
2.when popup size is less ,select is hiding.
3.What i am expecting.
Please suggest me what i can do to solve this.
Add CSS property overflow-y:visible on the main popup div:
This will make the inner content that is outside the main div top/bottom bounds to be rendered.
popupSelector {
overflow-y: visible;
}
Here is the documentation about overflow-y

Possible to use the same icon to open and close a modal?

I'm wondering whether I can use the "same" icon (or something that looks the same) that triggers a full-screen, semi-transparent Bootstrap modal (that I have customized) to pop up and then close it with an icon that is in the same location.
However, say it is initially a hamburger icon on the normal page, when I click the icon to pop up the modal menu, it is now under the modal. Is there a way to have it stay on top of even a modal? I tried z-index but I couldn't get it to work.
The tricky thing for me is that I wanted to have the icon transition from a hamburger to an X and then vice versa when it closed: http://sarasoueidan.com/blog/navicon-transformicons/
Initially I was hoping I could get the icon to transition and then somehow set the icon to layer on top of everything, including modals.
Any ideas or suggestions would be great, thank you.
It should be possible to do this with z-index. However, z-index only works with elements that have "position" set to something other than "static" (the default). Try adding position: relative to your open / close button and hopefully then you should be able to use z-index to keep the button in front of the overlay.
There's a good reference with more info about z-index on CSS Tricks.

How do I center a set of JQuery Mobile radio buttons in the viewport?

I'm making an app using JQuery Mobile on top of PhoneGap (Cordova). I used Codiqa to come up with a wireframe for my UI. It looks OK so far, but the group of radio buttons I'm going to use to change views with wasn't centred - it was off to the left by about 25px on a WVGA800-sized webkit browser. When scaled to a tablet shape, the group got further and further from the centre of the viewport.
Here's a jsFiddle link to my project with the problem unfixed - http://jsfiddle.net/jaspermogg/sahXy/1/
Here's a jsFiddle link to my project as fixed by me - http://jsfiddle.net/jaspermogg/NvMsK
I came up with a solution using JQuery, but I'm inexperienced and don't know which event to fire on.
When I load the UI in Webkit, it renders the UI pre-script, before refreshing after <1s to a post-script state. This looks lame. I have my script set up to run on $(window).load.
Questions:
What event should I be looking for, and could you show me how to implement that?
Is my script in the right place - should it be inside the page, the way it is, or outside? Or in head even?
It feels really stupid to be doing this with JQ - surely there's a way to do this with CSS?
Thanks in advance for any help offered! Cheers!
I guess I answered my own question in the comments above, so gonna formalise it by accepting my answer.
What I did in the end was -
(1) Set the radio button-containing div to visibility: hidden in the CSS.
(2) Find the widths of each radio button and add them together.
(3) Set the width of the radio button-containing div to the total width.
(4) Chain a change of the visibility property onto (3).
The CSS has to be set up like this -
#viewselector{
margin: 0 auto;
text-align: center;
visibility: hidden;
}
The code to do (1) to (4) is as follows -
$(document).ready(function(){
var idealwidth = 0
$(".ui-radio").each(function(){
idealwidth = idealwidth + $(this).width();
});
$("#viewselector").width(idealwidth).css('visibility','visible');
});
Hope this helps someone!

Resources