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

Toolbar box-shadow mask disappears when keyboard is up #2760

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

msdewitt
Copy link
Collaborator

@msdewitt msdewitt commented Jan 7, 2025

Fix for issue: 1785

Screenshot 2025-01-07 at 12 02 27 PM

Need to keep an eye on these changes to make sure no regression is introduced, but otherwise this seems to be a solid fix for keeping the box shadow on safari browser.

…lowX to visible when set as absolute position.
@raineorshine
Copy link
Contributor

Thanks for the submission! It would be nice if it was this easy, though I have my doubts. We know it was added for a reason. I think we should track down the commit message that describes the original use of overflowX.

Other behavior to test on mobile Safari with keyboard open and closed:

  • Toolbar scrolling
  • Overscroll
  • Color picker dropdown

@msdewitt
Copy link
Collaborator Author

msdewitt commented Jan 8, 2025

@raineorshine Alright, I finally found a solution to this issue after a few hours of work.

I managed to solve the problem with overflow by adding a relative bounds div wrap everything within the body tag, with an overflow: hidden property.

Everything seems to be working so far and I haven't found any issues with this solution so far. If you guys can find any regressions of bugs introduced by this fix, please let me know.

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2025-01-08.at.13.16.02.mp4

@msdewitt
Copy link
Collaborator Author

msdewitt commented Jan 8, 2025

@trevinhofmann I think things are working with this fix, but the puppeteer tests are all messed up.

@trevinhofmann trevinhofmann self-assigned this Jan 9, 2025
@trevinhofmann trevinhofmann self-requested a review January 9, 2025 05:06
Copy link
Collaborator

@trevinhofmann trevinhofmann left a comment

Choose a reason for hiding this comment

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

Testing locally, this proposal does seem to resolve the toolbar box-shadow issue. It also appears to introduce regressions.

the puppeteer tests are all messed up

Yes, there are several failing puppeteer tests. They are (mostly?) related to the Home icon being shifted down. This appears to be an unintended side effect and will need to be resolved.

Example:

font-size-18-default-initial-load-1-diff

@@ -29,8 +29,6 @@ const PuppeteerEnvironment: Environment = {
.catch((err: Error) => {
// using `console.log` here to avoid errors or logs being swallowed by vitest
// all of `console.error`, `console.warn` and `console.info` don't show up in the terminal
// eslint-disable-next-line no-console
console.log('Could not connect to browserless.')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please avoid irrelevant changes such as these.

@@ -50,8 +50,6 @@ const setup = async ({
break
case 'info':
case 'log':
// eslint-disable-next-line no-console
console[messageType](text)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please avoid irrelevant changes such as these.

@@ -37,7 +36,6 @@ const usePositionFixed = (): {

return {
position: position ?? 'fixed',
overflowX: position === 'absolute' ? 'hidden' : 'visible',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please explain this change? I'm a bit worried there will be unintended side effects from removing this attribute in the several places that use usePositionFixed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This change is needed to be removed and was discussed with @raineorshine in the ticket 1785. The reason that overflowX needed to be set when we switch to position absolute, was because there were no 'relative bounds' surrounding the app. When we switch to absolute, it moves part of the page off screen horizontally, thus giving the app a horizontal scroll bar that we don't need.

You can see the videos above attached to this pr, showing the horizontal scroll bar appear. This was a patchwork fix in the past and it needed to be reworked, because everytime the overflowX was set to hidden while the position was absolute, the boxShadow would disappear.

In order to resolve the issue of the boxShadow disappearing we can only find a way to remove this overflowX change (regarding the horizontal scrollbar), and to resolve this we need to add a relative bounds and overflow setting around all the apps which display in the root.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great explanation, thanks.

@raineorshine

This comment was marked as resolved.

@msdewitt
Copy link
Collaborator Author

msdewitt commented Jan 9, 2025

@raineorshine and @trevinhofmann, I think I am confused about what regressions this change has introduced. I can address them as soon as I know what they are.

The horizontal scroll bar has been fixed after adding the relative div surrounding the app root. However, since I added the div, the app's stability has improved and the scrolling doesn't 'jump arround' like it used too and the menu, toolbar, and overall app screen has been shifted slightly causing the puppeteer tests to fail.

@raineorshine
Copy link
Contributor

Great! If the horizontal scroll bar issue is fixed, then it should just be @trevinhofmann's comments above that require addressing:

  • Puppeteer failure - If your change altered the layout, you will need to adjust the layout to compensate for it.
  • console.log - Those are essential logging functions for test errors.

I will test at the end to ensure there are no other regressions!

@msdewitt
Copy link
Collaborator Author

@raineorshine I am not familiar with puppeteer, where should I update the snapshots with the new version in the code? I have been searching for it.

@raineorshine
Copy link
Contributor

I don't believe you should update any snapshots in this case. If a snapshot is failing, it means a visual regression was introduced. You can see in the diff that the home icon got shifted down. The code should be fixed so that the puppeteer tests pass and match the original snapshots.

You can find more information here: https://github.com/cybersemics/em/wiki/Testing#5-visual-snapshot-tests

@msdewitt
Copy link
Collaborator Author

Then, I cannot put this change in. Because this change adds a relative div box around the app to stabilize changes between position:absolute. The entire app's screenshot is shifted slightly. Technically, this is a 'regression' because of the change compared to the reference screenshot.

@raineorshine
Copy link
Contributor

Maybe you could find places to adjust the CSS to compensate for the layout shifts? We ideally want to preserve the existing layout while fixing the box-shadow issue. If the position: relative fix causes unintended side effects, it makes sense that they may need to be compensated for.

@msdewitt
Copy link
Collaborator Author

So this change is necessary because there originally was no 'relative bounds' within the app when anything was changed to position:absolute. This caused issues with another pull request of mine that will be also fixed by this pr. Because it didn't have any relative bounds, the IOS status bar would overlap with the apps. I originally put in a fix for this and was planning to push in another one.

However, this pr fixes that issue.

Adding this relative bounds prevents position:absolute from extending the app horizontally. In the current app, we just hid the extra horizontal panels by setting OverflowX: hidden. But this is not really a good fix compared to preventing the app from extending hozontially when an element's 'position' changes.

Long story short, this is a fix to a root problem of the overflowX.

If we don't want to push this in, I have not found another way to remove overflowX. and remove the horizontal app additions with a position change.

@msdewitt
Copy link
Collaborator Author

I had hoped that, knowing that the puppeteer tests where not reliable for this fix, we could still explore this pr and push in the change that would fix a lingering issue. But I wanted to be very careful about it, so I asked for help in reviewing it.

@raineorshine
Copy link
Contributor

raineorshine commented Jan 13, 2025

Yes, overall this seems like a good change, since allowing the app to extend horizontally is undesirable.

Regardless of how correct this change is, it causes a visual regression which impacts the user experience. Generally we want to patch regressions in the same PR. If we merged this now and then fixed the positioning in a separate PR, we would have a "bad" commit in the commit history, which can interfere with git bisect. It's better to fix the layout in this PR so that we get the benefits of both.

@msdewitt
Copy link
Collaborator Author

@raineorshine Do you know any advice on how to handle updating the patch regressions then? I don't know how to make any more progress on this pr.

@raineorshine
Copy link
Contributor

I'm not sure what you mean by updating the patch regressions. This looks to be a CSS issue. Are you able to reproduce it in Chrome?

@msdewitt
Copy link
Collaborator Author

@raineorshine No, this issue is caused by what I mentioned earlier in this thread.
Screenshot 2025-01-16 at 2 58 18 PM

<div style="position: relative; overflow: hidden;">

This div is newly added as a bounds around the entire app in order to fix the problem with position: absolute causing a horizontal shift occurring due to there not being any relative bounds within the app.

The only problem is, I can't move this CSS styling to any other places without causing other styling changes within the app. Its best as it is right now. However, because of this new div surrounding everything, the puppeteer tests are failing.

So here comes my dilemma about what I had been asking about. I can either discard this fix and this pr completely, because the fix is relative niche as it only occurs on safari. Or we can update the saved screenshots of what the CSS used to look like to match these on coming changes.

@msdewitt
Copy link
Collaborator Author

And I don't know how to update those saved screenshots with puppeteer. I am stuck.

@raineorshine
Copy link
Contributor

I think you might be missing the point here. Updating the screenshots is like turning off the fire alarm off when there is a fire. The puppeteer tests are trying to tell us something. In this case, it's not a fire, but a flaw in the construction. It's like the contractor neglected to put a vent in the bathroom. But in order to put in the vent, we need to move the sink and re-paint.

I can reproduce the regression very easily in Chrome. It's clearly a CSS issue. There are some other styles that might need to be adjusted or elements moved to accommodate the new relative container. Is this something you're interested in doing? If not, that's totally okay. It's up to you whether you want to continue on this. The success criteria is resolution of the box-shadow issue without any regressions. I can confidently say that it is possible. If you're not up for it, I totally understand.

@msdewitt
Copy link
Collaborator Author

@raineorshine I do realize the point of the tests. However, I might be confused about how to update new CSS changes if the puppeteer service prevents differences of a certain amount.

There are 6 tests that are failing due to less than 1% difference in pixels.

I may not be able to handle this final push to fix these changes due to my lack of understanding on this aspect. I understand that puppeteer is comparing differences and warning about it, but it shouldn't be like traditional tests like unit tests where it tests the logic.

You are right that I may not be up for it, because I have been thinking about this for a bit too long to continue to admit that I can finish it according you the code review comments I was given.

@raineorshine
Copy link
Contributor

If these were imperceptible differences, I would totally understand that. But the visual regression is quite clear. It is a CSS issue that can be troubleshooted like any CSS issue. If you start looking at the home icon and the nav bar, I bet you would start to get some clues.

It's totally up to you though. I've appreciated your help up to this point!

Current Behavior

4cdb704

PR Screenshot 2025-01-16 at 10 05 58 PM

Expected Behavior

main

main Screenshot 2025-01-16 at 10 05 10 PM

@msdewitt
Copy link
Collaborator Author

Oh, if this is the issue it's not a difficult fix.
Is the home button supposed to be 'sticky' at the bottom of the left screen?

Currently, it exists but you need to scroll down the page to see it.

Screenshot 2025-01-16 at 4 18 30 PM Screenshot 2025-01-16 at 4 18 25 PM

@raineorshine
Copy link
Contributor

raineorshine commented Jan 16, 2025

Oh, if this is the issue it's not a difficult fix.

Yes, this is what the puppeteer snapshot tests show us. You should be able to see it in the diff on your machine when you run yarn test:puppeteer and in the diff upload artifacts that can be downloaded from GitHub Actions.

Is the home button supposed to be 'sticky' at the bottom of the left screen?

Yes, exactly. You can test on main or on staging to see the exact behavior.

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.

3 participants