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(modal): Fix vertical position of modal when ".reveal-modal" has % "top" property #1

Merged
merged 2 commits into from
Aug 15, 2018

Conversation

kristinalim
Copy link
Member

@kristinalim kristinalim commented Aug 15, 2018

Fix vertical position of modal when .reveal-modal has % "top" property

I also submitted this PR to the main repository: yalabot#319

Description

Currently, if the "reveal-modal" CSS class is assigned an n% "top" CSS property, the modal would be positioned n px from the top of the viewport.

An absolute-positioned element with % "top" property that is hidden through display: none; does not evaluate to the same value as a visible one for the following JS, which is used for the modal:

window.getComputedStyle(element).top

The computed "top" value for the hidden element is still the % value, while it is the computed px value if the element is visible or when using visibility: hidden, as demonstrated in this Plunker.

$modalStack.open expects the expression above to return the px value, so a 10% value gets treated as 10px. This is not the desired behavior, and a big limitation now that people use a big range of screen sizes.

The faux modal is temporarily inserted with z-index: -1 (JS), display: none (CSS), and visibility: hidden (CSS).

As a workaround, this commit assigns display: block (JS) to the faux modal.

Release notes

  • Fix vertical position of modal when ".reveal-modal" has % "top" property

Changelog Category: Bug Fixes - modal

@kristinalim kristinalim added the bug Something isn't working label Aug 15, 2018
@kristinalim kristinalim self-assigned this Aug 15, 2018
@kristinalim kristinalim changed the title Fix vertical position of modal when ".reveal-modal" has % "top" property fix(modal): Fix vertical position of modal when ".reveal-modal" has % "top" property Aug 15, 2018
@kristinalim kristinalim force-pushed the fix-modal-wrong_position_when_percent_top_property branch from ee2d666 to 93d3d87 Compare August 15, 2018 09:21
An absolute-positioned element with % "top" property that is hidden
through "display: none;" does not evaluate to the same value as a
visible one for the following JS:

    window.getComputedStyle(element).top

The computed "top" value for the hidden element is still the % value,
while it is the computed px value if the element is visible or when
using "visibility: hidden;". This is demonstrated in the following
Plunker:

    http://run.plnkr.co/preview/cjkut64np00072y6ccj3tmqem/

$modalStack.open expects the expression above to return the px value,
so a "10%" value gets treated as "10px". This is not the desired
behavior, and a big limitation now that people use a big range of screen
sizes.

The faux modal is temporarily inserted with "z-index: -1" (JS),
"display: none" (CSS), and "visibility: hidden;" (CSS).

As a workaround, this commit assigns "display: block" (JS) to the faux
modal.
@kristinalim kristinalim merged commit 9e81b57 into 0.8.x Aug 15, 2018
kristinalim added a commit to kristinalim/openfoodnetwork that referenced this pull request Aug 15, 2018
There is a bug in the handling of % values for the "top" CSS property of
the modals. See details here:

openfoodfoundation/angular-foundation#1

A PR to the original repository has also been submitted, but the project
doesn't seem to be active anymore:

yalabot/angular-foundation#319

The bug was causing the 10% "top" CSS property for the modal to be
treated as 10px.
kristinalim added a commit to kristinalim/openfoodnetwork that referenced this pull request Aug 26, 2018
There is a bug in the handling of % values for the "top" CSS property of
the modals. See details here:

openfoodfoundation/angular-foundation#1

A PR to the original repository has also been submitted, but the project
doesn't seem to be active anymore:

yalabot/angular-foundation#319

The bug was causing the 10% "top" CSS property for the modal to be
treated as 10px.
kristinalim added a commit to kristinalim/openfoodnetwork that referenced this pull request Aug 26, 2018
There is a bug in the handling of % values for the "top" CSS property of
the modals. See details here:

openfoodfoundation/angular-foundation#1

A PR to the original repository has also been submitted, but the project
doesn't seem to be active anymore:

yalabot/angular-foundation#319

And to another fork of the repository:

cwadrupldijjit/angular-foundation#1

The bug was causing the 10% "top" CSS property for the modal to be
treated as 10px.
kristinalim added a commit to kristinalim/openfoodnetwork that referenced this pull request Sep 3, 2018
There is a bug in the handling of % values for the "top" CSS property of
the modals. See details here:

openfoodfoundation/angular-foundation#1

A PR to the original repository has also been submitted, but the project
doesn't seem to be active anymore:

yalabot/angular-foundation#319

And to another fork of the repository:

cwadrupldijjit/angular-foundation#1

The bug was causing the 10% "top" CSS property for the modal to be
treated as 10px.
kristinalim added a commit to kristinalim/openfoodnetwork that referenced this pull request Sep 5, 2018
There is a bug in the handling of % values for the "top" CSS property of
the modals. See details here:

openfoodfoundation/angular-foundation#1

A PR to the original repository has also been submitted, but the project
doesn't seem to be active anymore:

yalabot/angular-foundation#319

And to another fork of the repository:

cwadrupldijjit/angular-foundation#1

The bug was causing the 10% "top" CSS property for the modal to be
treated as 10px.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant