What happened?
Description
By default, the live preview retains/restores the current scroll position when a field it's refreshed. However, this doesn't work if you use scroll-behavior: smooth on the HTML element:
html {
@media (prefers-reduced-motion: no-preference) {
scroll-behavior: smooth;
}
}
This happens without using iframe resizer (useIframeResizer is set to false). Using iframe resizer fixes this in some cases, but unfortunately breaks the preview in other ways.
Steps to reproduce
- Include the CSS above in a template.
- Open the live preview for any entry and scroll down.
- Edit any field so that the live preview refreshed. The live preview will reset to the start of the page.
Expected behavior
Scroll position should be retained/restored even when using scroll-behavior: smooth. If that is unfeasible, the live preview could inject some CSS to overwrite the scroll-behavior property for the html element, that should be an acceptable workaround.
Craft CMS version
4.5.7
PHP version
8.2
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response
What happened?
Description
By default, the live preview retains/restores the current scroll position when a field it's refreshed. However, this doesn't work if you use
scroll-behavior: smoothon the HTML element:This happens without using iframe resizer (
useIframeResizeris set tofalse). Using iframe resizer fixes this in some cases, but unfortunately breaks the preview in other ways.Steps to reproduce
Expected behavior
Scroll position should be retained/restored even when using
scroll-behavior: smooth. If that is unfeasible, the live preview could inject some CSS to overwrite thescroll-behaviorproperty for thehtmlelement, that should be an acceptable workaround.Craft CMS version
4.5.7
PHP version
8.2
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response