-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[feedback-widget] feat: lazy load feedback widget component #13616
Conversation
There’s more to do, but this is a start… - remove `font-family: sans-serif` along the way - remove components/feedback-widget/presets in favor of utils/presets.breakpoints
Could we lazy load it on hover or click? |
onMouseOver actually? |
Sure, would require some reorganization (as we would want to show button always) and start lazy loading on hover (and focus :) ). Probably would also need some extra handling to queue click events if it wan't loaded yet to not have glitchy experience |
I can address this tomorrow |
- chose to reduce the border around the „emoji toggle buttons“ from 3 to 1px - add horizontal margin for screens below desktop/lg
…user has no intention of using it
Preview link after addressing lazy loading on hover/focus - https://5cc1c705443c86d19f93cd46--gatsby-org-pieh-previews.netlify.com/docs/ |
Maybe use intersection observer then? A little more head start. It's 23kb so not that much code. |
The animations are great btw 😍 |
All hail @greglobinski ! :)
Would you want to show button before we load full widget? Because if yes, then we will still have same problem on slower connection - user can click button before widget is ready to be used. If we don't show button, then there would be this weird (IMO) interaction on mobile, when you scroll to the bottom, suddenly button would "randomly" show up (on desktop button is fixed in viewport) |
In any case - I'll try to repurpose the "working" spinning icon that is used when submitting feedback |
Because the button has a scale, the svg is pretty blurry when transitioning, it also isn't super fluent better to set the width & height of the button to the correct value and scale down instead of scaling up. 🙈 Perhaps add a spinner to the button or set the button to disabled to show that something is happening. We could also leverage suspense for this to only show this when it's taking long. |
In testing the preview link with the keyboard and Voiceover, I can't seem to trigger the feedback widget to open with the space or enter keys. There is also no visible focus style–possibly because of the |
(I think) I didn't change anything related to styling (other than moving few things around), so this potentially would need to be mentioned in main PR - #13550
I don't want to "disable" button, as it would loose focusability (I think). Suspense I think is problematic right now for us (SSR), but I can implement this by hand.
What browser were You using? It seems to work on Chrome for me (both navigation / toggling widget with space/enter and visible focus), but I want to take another look if I can reproduce this |
I used Safari and Chrome. It doesn't work for me in either, even without Voiceover on. |
For me too, also on FF (Ubuntu)
@marcysutton Did it work for you before? |
@wardpeet Are you pointing the |
I was able to reproduce this in Safari. This happens because the initial button is removed once full widget loads, and focus is not being transferred to toggle button from full widget. It's pretty tough tho, because re-focusing button has visible drop-down animation (suddenly orange "outline" disappear and is animated back in). I hoped using same |
…aded within 1 second of a button click
I forgot to add preview for latest version of it - https://5cc73d8862760198feb5f6c5--gatsby-org-pieh-previews.netlify.com/docs/ It should also fix focus/hover box shadow on toggle button in Safari |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@greglobinski yes indeed :)
@pieh looks good. I would keep the focus inside the feedback widget until closed but that's another PR :)
} | ||
return state | ||
}) | ||
}, 1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
following rail practices https://developers.google.com/web/fundamentals/performance/rail this should be 100ms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no strong opinion on this (but I think 100ms might be to short?) - I've used timeout we use already in core
gatsby/packages/gatsby/cache-dir/navigation.js
Lines 75 to 82 in f4e8d61
// Start a timer to wait for a second before transitioning and showing a | |
// loader in case resources aren't around yet. | |
const timeoutId = setTimeout(() => { | |
emitter.emit(`onDelayedLoadPageResources`, { pathname }) | |
apiRunner(`onRouteUpdateDelayed`, { | |
location: window.location, | |
}) | |
}, 1000) |
for plugins like
gatsby-plugin-nprogress
to show loader on page transitions
What should we do with this PR @pieh? |
Oh, hmm, if this didn't prove to be problem we can just discard this PR (if we will want to get back to it - I will keep branch around, tho it's pretty outdated at this point) |
This is PR against #13550
After running webpagetest:
first interactive seems significantly faster on lazy loaded one and feedback component isn't critical to be immediately shown on initial mount / page transition so I think tradeoff of (slightly) delaying it in favour of faster overall interactivity seems good idea
Preview for this version available at https://5cc0c487ba5e4e79a0a62cf8--gatsby-org-pieh-previews.netlify.com/docs/