Sanity: Opening fieldsets scrolls the editor view to the top

Created on 26 Oct 2020  路  3Comments  路  Source: sanity-io/sanity

Describe the bug

Opening collapsible fieldsets for the first time when opening a document forces the editor view to scroll to the top. Objects work fine and the document doesn't scroll on closing fieldsets, however!

_I believe this is due to focus management_: maybe array and image fields have a different mechanism for focus or their focus() directives aren't being called properly. Just a guess 馃

Also, I'm not sure if this is a bug or a design choice, but fields aren't focused when you open and close objects and fieldsets. Maybe we should focus on the first one?

To Reproduce

Simply create a fieldset with one or more fields and place it under other fields that will make the document scrollable. Then open the document and open the fieldset to see the unintended behavior.

Expected behavior

No scrolling when opening fieldsets.

Video

I've recorded a video of the bug happening on the latest version of Sanity. Notice how it only happens the first time I open the document.

Which versions of Sanity are you using?

@sanity/cli             2.0.5 (up to date)
@sanity/base            2.0.7 (up to date)
@sanity/cli             2.0.5 (up to date)
@sanity/color-input     2.0.5 (up to date)
@sanity/components      2.0.7 (up to date)
@sanity/core            2.0.5 (up to date)
@sanity/dashboard       2.0.5 (up to date)
@sanity/default-layout  2.0.7 (up to date)
@sanity/default-login   2.0.5 (up to date)
@sanity/desk-tool       2.0.8 (up to date)
@sanity/form-builder    2.0.8 (up to date)
@sanity/schema          2.0.1 (up to date)
@sanity/vision          2.0.5 (up to date)

What operating system are you using?

Windows - latest version

Which versions of Node.js / npm are you running?

6.14.8
v14.13.0

Additional context

This started happening when you launched the first version of Presence and the new PT editor, before it was working fine (version 1.149, if I'm not mistaken 馃槉)

Let me know if you have any further questions, thank you for Sanity! 馃檶

Bug UX Studio

Most helpful comment

Thank you for reporting! 馃檹 We are aware of this (very annoying) bug and have added it to our internal tracker 馃憤

All 3 comments

Thank you for reporting! 馃檹 We are aware of this (very annoying) bug and have added it to our internal tracker 馃憤

Will this bug fix also cover the following scenario:
A document uses another object with various fields. When one of the last fields are clicked/gains focus, focus jumps to the first defined field on the object.

We have also encountered this bug as well in the 1.150 build. This becomes very problematic on our pages with deep list-based views that are organized using fieldsets.

@sanity/base            1.150.7
@sanity/components      1.150.7
@sanity/core            1.150.7
@sanity/default-layout  1.150.7
@sanity/default-login   1.150.1
@sanity/desk-tool       1.150.7
@sanity/vision          1.150.6

Is there any workaround pending a patch being released?

We tried using a focus on our custom component (that is embedded in the fieldset) but that doesn't seem to work. is there like a fieldset focus ability?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

camjc picture camjc  路  4Comments

robinpyon picture robinpyon  路  4Comments

davesag picture davesag  路  6Comments

mickeyreiss picture mickeyreiss  路  5Comments

robinpyon picture robinpyon  路  4Comments