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

fix: modify calculation for dialog defaultWidth which caused visual bug #133

Merged
merged 1 commit into from
Sep 18, 2020

Conversation

mateomustapic
Copy link
Contributor

This PR fixes an issue described in https://issues.liferay.com/browse/LPS-120758 ,visual bug in Chrome (scrollbar) and in Firefox (whitespace) in Source dialog box.
This issue was caused by CodeMirror plugin line number width not included in dialog size calculation.

To test this fix:

  1. Build CKEditor with this change
  2. Access to portal.
  3. Go to Web Content.
  4. Add a content.
  5. In content field, click Source button in ckeditor toolbar to go to source view.
  6. Type any text
  7. Click the Expand icon next to the Source button to preview source dialog.

Before Chrome
beforechrome

Before Firefox
beforefirefox

After Chrome
afterchrome

After Firefox
afterfirefox

Copy link
Contributor

@carloslancha carloslancha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just left a nit. @julien will know better the impact of this change :)

var defaultWidth = size.width * 0.5 - 10;
var padding = 40;

var defaultWidth = size.width * 0.5 - padding;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this padding var being used elsewhere? If not I'd avoid creating the variable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, it's not being used anywhere, but I'm guessing @mateomustapic added this to avoid a "magic number"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not 0.5 already a magic number? 😛

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it translates pretty obviously to "half" so not all that magical, unlike padding which is totally arbitrary. You probably wouldn't want to write:

var padding = 40;

var half = 0.5;

var defaultWidth = size.width * half - padding;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not 0.5 already a magic number? stuck_out_tongue

yeah, well you make a point; but I always read that as "whatever / 2"

x / 2 == x * 0.5

Copy link
Contributor

@julien julien Sep 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I hadn't seen @wincent 's comment before adding mine: now that I've read it, I agree about avoiding those magic numbers everywhere

@julien
Copy link
Contributor

julien commented Sep 17, 2020

gonna test this right now 🥳

@julien
Copy link
Contributor

julien commented Sep 17, 2020

@mateomustapic so I tested this and here's what I think (with screenshots):

The bug seems to be gone in Chrome:

and also seems fixed when you have the devtools open or if the window has a smaller size:

Same thing, in Firefox:

And in Firefox with the devtools open:

firefox02

But while we're looking at it, I also would consider fixing this, because it seems related (I'm not saying it's mandatory but if it's not too hard to fix, why not)

@julien
Copy link
Contributor

julien commented Sep 17, 2020

@mateomustapic concerning the editor's height in the dialog, I'm going to to that in #132
Just make sure this works fine in IE11 as well please. Thanks

@mateomustapic
Copy link
Contributor Author

@mateomustapic concerning the editor's height in the dialog, I'm going to to that in #132
Just make sure this works fine in IE11 as well please. Thanks

hey @julien

Just tested this in IE, and works as in other browsers.
Before
ie_before

After
ie_witdth_test

@julien
Copy link
Contributor

julien commented Sep 18, 2020

Ok thanks for confirming @mateomustapic, I'm still going to give it a quick test run in DXP because who knows.

Could you tell me what you think of @wincent's comment?

I personally think it's better to avoid those magic numbers, so I'd be OK to do it both for half (0.5) and padding (40)

@carloslancha does that seem reasonable to you as well?

@mateomustapic
Copy link
Contributor Author

mateomustapic commented Sep 18, 2020

Ok thanks for confirming @mateomustapic, I'm still going to give it a quick test run in DXP because who knows.

Could you tell me what you think of @wincent's comment?

I personally think it's better to avoid those magic numbers, so I'd be OK to do it both for half (0.5) and padding (40)

@carloslancha does that seem reasonable to you as well?

@julien As I can see, @wincent says "_Well, it translates pretty obviously to "half" so not all that magical, unlike padding which is totally arbitrary. You probably wouldn't want to write .... var defaultWidth = size.width * half - padding;" , meaning adding of padding variable is ok, but not adding of half variable, where 0.5 value is self-explanatory.

@julien
Copy link
Contributor

julien commented Sep 18, 2020

I need to wear glasses

@jbalsas
Copy link
Contributor

jbalsas commented Sep 18, 2020

Why don't simply use foo / 2?

That's more obviously a "halving" operation than foo * .5 :)

@julien
Copy link
Contributor

julien commented Sep 18, 2020

@jbalsas that's also true - even more obvious

@mateomustapic
Copy link
Contributor Author

yeah, it's more readable to divide by 2 than multiply 0.5.

@julien
Copy link
Contributor

julien commented Sep 18, 2020

The change looks good to me - so I'm merging this one

@julien julien merged commit e281cbc into liferay:master Sep 18, 2020
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

Successfully merging this pull request may close these issues.

5 participants