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: iOS popup close button behaviour #2288

Merged
merged 6 commits into from
May 15, 2024
Merged

Conversation

jfmcquade
Copy link
Collaborator

@jfmcquade jfmcquade commented Apr 10, 2024

PR Checklist

  • PR title descriptive (can be used in release notes)

Description

Resolves a bug where the popup close button would appear behind the popup window in the case that the popup contained scrollable content.

Testing

Appetize build available here.

Dev notes

A bug on iOS causes some CSS rules to not be applied to some elements under certain conditions, manifesting in the bugs detailed in the linked issues. This PR provides a workaround in the form of a CSS mixin that can be applied to any problematic element, within a new overrides.ios.scss file. Originally, this approach was used to provide a workaround for issues #2262 and #2287. These have both now been closed by standalone PRs which address their specific issues more directly: #2289 and #2302 respectively.

Git Issues

Closes #2274

Screenshots/Videos

The close button on a scrollable popup rendering correctly, resolving #2274 (example_pop_ups template)
Pop-up

Copy link
Member

@chrismclarke chrismclarke left a comment

Choose a reason for hiding this comment

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

Nice you were able to figure out a workaround, although still a bit strange as I thought most of these type of hacks usually effected animations more than static content, but guessing it has some knock-on here for the root issue too.

Given that these hacks are currently being applied to all devices/browsers it might be a bit cleaner to create a separate overrides.ios.scss file that keeps all of these in one clear file instead of spread out across various components.

This would likely require populating a data-attribute to the document body when the main component loads to reference the platform <body data-platform='ios'> (reading the platform from capacitor).

That way the override file can scope accordingly, e.g.

body[data-platform='ios']{
   ion-button[data-variant~="card"]{
       @include mixins.hack-webkit-reset;
 }
}

I'd also probably recommend renaming the mixing to be more illustrative of what it does e.g. force-gpu-accelearation

@chrismclarke
Copy link
Member

Also interestingly, I'm now running the webkit browser using playwright and can replicate a bunch of the ion-toggle issues but I don't see the browser popup close (so that might be mobile-browser specific? - did you ever clarify which issues were on safari desktop as well as mobile app?)...

I'm also noticing a bunch of these issues relate specifically to ion-toggle but we seem to be using a legacy version of the component (various deprecated upgrade warnings) - it might be worth trying to update these to see if it fixes anything without the added workarounds

@chrismclarke
Copy link
Member

Looking more closely at specific comp_button - it still feels to me more an issue with how the button is coded. We're using absolute positioning to nest child rows however not explicitly stating what the absolute is relative too (should be parent container), so that leaves a bit of ambiguity to be filled in.

@chrismclarke
Copy link
Member

@jfmcquade
See #2289
I think it might be a more concrete solution (although will need more work to address other components that have similar problems).

@jfmcquade
Copy link
Collaborator Author

did you ever clarify which issues were on safari desktop as well as mobile app?

This prompted me to check again: I can't replicate #2274 on desktop Safari, but the #2287 I can, which should possibly allow for easier debugging.

I'm also noticing a bunch of these issues relate specifically to ion-toggle but we seem to be using a legacy version of the component (various deprecated upgrade warnings) - it might be worth trying to update these to see if it fixes anything without the added workarounds

Indeed, there's an issue, #2212, which it may be time to prioritise.

Looking more closely at specific comp_button - it still feels to me more an issue with how the button is coded. We're using absolute positioning to nest child rows however not explicitly stating what the absolute is relative too (should be parent container), so that leaves a bit of ambiguity to be filled in.

Brilliant, thanks, I've approved #2289. I'll take another look at #2274 with this position issue in mind (I did try to exhaustively set positions on various elements to resolve it, but I think worth revisiting now I understand the problem from your solution). As for #2287, I don't think the it's the same issue in terms of the position property, but I am reassured by your account of an ambiguity in the CSS that is interpreted differently across various browsers, which at least provides a possible high-level explanation.

I'll see again if I can address the issues with the other two components directly with that in mind, otherwise I will implement the refactoring of this PR that you suggest above and will suggest that we go ahead with this as a workaround.

@chrismclarke
Copy link
Member

chrismclarke commented Apr 12, 2024

I'll see again if I can address the issues with the other two components directly with that in mind, otherwise I will implement the refactoring of this PR that you suggest above and will suggest that we go ahead with this as a workaround.

Yeah the box-shadow issues seem very weird generally, although maybe it's the background color getting 'lost' somehow (and hardcoding might fix?). I can't replicate either of the outstanding issues on webkit browser so possibly is more a mobile browser issue, which may be fixed through a combination of tidying up ambiguous style rules and enabling hardware acceleration.

I think it would still be preferable if we can fix via regular CSS as it does seem that GPU acceleration may have trade-offs:
https://mercimichel.medium.com/don-t-abuse-enabling-gpu-acceleration-on-ios-95520da2428

But I expect for scroll-specific bugs it may well be the only way to fix until we better-optimize components and rendering logic more generally

Copy link
Collaborator

@esmeetewinkel esmeetewinkel left a comment

Choose a reason for hiding this comment

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

Functional test passed on Appetize link

@github-actions github-actions bot added fix and removed fix labels May 8, 2024
@jfmcquade jfmcquade changed the title fix: CSS not applied correctly on some elements on iOS fix: iOS popup close button behaviour May 8, 2024
@github-actions github-actions bot added fix and removed fix labels May 8, 2024
@jfmcquade jfmcquade changed the base branch from master to fix/data-items-order May 8, 2024 16:16
@jfmcquade jfmcquade changed the base branch from fix/data-items-order to master May 8, 2024 16:16
@github-actions github-actions bot added fix and removed fix labels May 8, 2024
@github-actions github-actions bot added fix and removed fix labels May 8, 2024
@@ -103,6 +109,7 @@ export class AppComponent {

private async initializeApp() {
this.platform.ready().then(async () => {
this.platforms = this.platform.platforms().join(" ");
Copy link
Collaborator Author

@jfmcquade jfmcquade May 8, 2024

Choose a reason for hiding this comment

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

Originally I planned to use Capacitor.getPlatform(), which just returns "web", "ios" or "android". But there are two potential reasons to prefer Platform.platforms():

  1. In the future we may want to to extend our platform specific CSS to apply rules based on platform types within this hierachy (e.g. "mobile")
  2. When running on a web browser with device mode active, Capacitor.getPlatform() returns "web", but platform.platforms() returns a list representing the emulated device. E.g. in Chrome with device mode active and set to iPhone SE:
    Screenshot 2024-05-08 at 16 06 57
    This seems desirable as it allows us to test functionality when running on web, although there may be issues with this that would make the simple platform more suitable

Copy link
Member

Choose a reason for hiding this comment

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

Makes a lot of sense, also appreciate storing it as string instead of array to use with the css selectors and providing the option for various levels of platform-specific override. I've just added an extra line to the comment as a reminder of this with 6b49c25

@jfmcquade
Copy link
Collaborator Author

@chrismclarke I've requested a re-review as I've refactored according to your suggestions, and updated the PR description to explain that this workaround fix is now applied in just one case, but could be extended to cover other similar cases as they occur.

Copy link
Member

@chrismclarke chrismclarke left a comment

Choose a reason for hiding this comment

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

Thanks @jfmcquade - looks really good to me, appreciate being able to just apply the styles for a specific platform subset and the separation of core from override scss.

I haven't tested anything on ios, but happy to merge here and just review any further follow-ups for specific issues as they come up

@github-actions github-actions bot added fix and removed fix labels May 13, 2024
@esmeetewinkel esmeetewinkel merged commit 6dd1267 into master May 15, 2024
6 checks passed
@esmeetewinkel esmeetewinkel deleted the fix/ios-button-card branch May 15, 2024 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] iOS: popup close button behaviour
3 participants