? ? Pending

User tests: Successful: Unsuccessful:

avatar cheesegrits
cheesegrits
8 Dec 2018

Pull Request for Issue #23243.

Summary of Changes

Fix for bounds detection in the calendar field. Currently, calendar fields at the bottom of the viewport will be opened off screen, if the window has been scrolled down.

See #23243

Testing Instructions

Add a calendar field to a long form, for example the Options fieldset in the com_content backend. Around line 604 in administrator/components/com_content/models/forms/article.xml, just before the close fieldset, add ...

			<field
					name="foobar"
					type="calendar"
					label="foobar"
					description="foobar"
					translateformat="true"
					showtime="true"
					size="22"
					filter="user_utc"
			/>

Now edit an article, switch to the Options tab and scroll down so the new 'foobar' date field is at the bottom of the window. Open the calendar widget.

Expected result

Widget should open above the field, fully visible

Actual result

Widget opens below the field, mostly off screen.

Apply this PR, and the widget will open correctly, above the field. No other behavior is changed, dates on non scrolled pages, or near the top of the viewport, are not affected.

Documentation Changes Required

none

avatar cheesegrits cheesegrits - open - 8 Dec 2018
avatar cheesegrits cheesegrits - change - 8 Dec 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 8 Dec 2018
Category JavaScript
avatar joomla-cms-bot joomla-cms-bot - edited - 8 Dec 2018
avatar Quy Quy - change - 8 Dec 2018
Title
Cheesegrits patch 1
Calendar off screen detection broken when window scrolled
avatar cheesegrits
cheesegrits - comment - 8 Dec 2018

Just to be clear, the issue is that getBoundingClientRect() returns coordinates relative to top left of the viewport, not the document:

https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect

... so scrollY should not be added to the window's innerHeight when comparing that with the bottom of the calendar's container.

avatar cheesegrits cheesegrits - change - 8 Dec 2018
The description was changed
avatar cheesegrits cheesegrits - edited - 8 Dec 2018
avatar Quy
Quy - comment - 8 Dec 2018

Please apply the same change to calendar.min.js.

avatar cheesegrits
cheesegrits - comment - 10 Dec 2018

What minifier should I use?

avatar mbabker
mbabker - comment - 10 Dec 2018

There isn't a standard one for 3.x, the last time I did something with JavaScript on 3.x I used https://jscompress.com/

avatar cheesegrits cheesegrits - change - 10 Dec 2018
Labels Added: ?
avatar cheesegrits
cheesegrits - comment - 10 Dec 2018

OK, I finally took the time to figure out how to minify automagically in PHP Storm. Used uglifyjs which is what I use for my component (although I do it in a Grunt build script, as our paths get a bit too complicated to do on the fly).

The result seems to be a little larger than the original, not sure what it was originally compressed with, but nothing major.

avatar cheesegrits cheesegrits - change - 10 Dec 2018
The description was changed
avatar cheesegrits cheesegrits - edited - 10 Dec 2018
avatar infograf768
infograf768 - comment - 11 Dec 2018

I have tested this item successfully on b7f6f81

OK here, although I do not have the issue on Firefox Macintosh.
Before patch:
calendar-before
After patch
calendar-after


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23244.
avatar infograf768
infograf768 - comment - 11 Dec 2018

I have tested this item successfully on b7f6f81

OK here, although I do not have the issue on Firefox Macintosh.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23244.

avatar infograf768 infograf768 - test_item - 11 Dec 2018 - Tested successfully
avatar infograf768
infograf768 - comment - 11 Dec 2018

Difference with using https://jscompress.com/ is a bit much imho as it is around 4-5KB

avatar cheesegrits
cheesegrits - comment - 11 Dec 2018

@infograf768 OK, I'll redo the minification.

Also, the issue kind of depends on browser and surrounding CSS. The example you posted, your browser has resized the container the calendar is in and made the page longer to accommodate it (and probably auto-scrolled the page to bring it into view). But some browsers won't do that, and some front end site templates (like Gantry) prevent the container being auto-resized, so the calendar literally becomes inaccessible.

avatar Quy
Quy - comment - 11 Dec 2018
avatar cheesegrits
cheesegrits - comment - 12 Dec 2018

I'm just reluctant to use online minifiers, as there's no way to tell if malicious code is being injected. So I'm dicking around with a few options in PHP Storm, see if I can get the size down a bit.

avatar cheesegrits
cheesegrits - comment - 12 Dec 2018

@infograf768 - OK, back down to 25k, the original size.

avatar trob
trob - comment - 12 Dec 2018

I have tested this item successfully on 0478781


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23244.

avatar trob
trob - comment - 12 Dec 2018

I have tested this item successfully on 0478781


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23244.

avatar trob trob - test_item - 12 Dec 2018 - Tested successfully
avatar Quy
Quy - comment - 12 Dec 2018

I have tested this item successfully on 0478781


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23244.

avatar Quy
Quy - comment - 12 Dec 2018

I have tested this item successfully on 0478781


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23244.

avatar Quy Quy - change - 12 Dec 2018
Status Pending Ready to Commit
avatar Quy
Quy - comment - 12 Dec 2018

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23244.

avatar Quy Quy - test_item - 12 Dec 2018 - Tested successfully
avatar mbabker mbabker - change - 18 Dec 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-12-18 02:42:40
Closed_By mbabker
Labels Added: ?
avatar mbabker mbabker - close - 18 Dec 2018
avatar mbabker mbabker - merge - 18 Dec 2018
avatar cheesegrits
cheesegrits - comment - 18 Dec 2018

Thanks, guys 'n' gals.

Add a Comment

Login with GitHub to post a comment