-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Improve preview feedback in fetch query #1153
Conversation
Your Render PR Server URL is https://toolpad-pr-1153.onrender.com. Follow its progress at https://dashboard.render.com/web/srv-cd42241gp3jra0rsd3jg. |
debd7eb
to
b5be53f
Compare
b5be53f
to
b93d32c
Compare
I don't feel like this is the right approach. We should leave the user in control of navigating the UI. Perhaps we can make the word "transform" in the warning clickable to open the tab? |
I personally feel differently about this. Can you provide an example where you wouldn't want to check how transform is defined after getting this message? -edit: I'd consider it a very similar pattern to when you get error in a long form and browser scrolls to the actual error so you are not left hanging wondering what's wrong |
Co-authored-by: Bharat Kashyap <bharatkashyap@outlook.com> Signed-off-by: Vytautas Butkus <vytautas.butkus@gmail.com>
Co-authored-by: Bharat Kashyap <bharatkashyap@outlook.com> Signed-off-by: Vytautas Butkus <vytautas.butkus@gmail.com>
Co-authored-by: Bharat Kashyap <bharatkashyap@outlook.com> Signed-off-by: Vytautas Butkus <vytautas.butkus@gmail.com>
It's not about interested in it or not. It's about not disrupting the UI without user interaction. Maybe the backend takes 7 seconds to respond and in those 7 seconds I may have started to look in one of the other tabs. Suddenly out of nothing the tab changes and I'm pulled out of my context. Instead, in the preview message give a button to open the relevant tab so that I can correct it in a time that makes more sense for me as a user (e.g. when I'm inspecting the message in the preview window). Another option is to mark the tab with a badge to tell the user there is some important action to be taken there. edit: there's an important difference with scrolling to a validation error. it's that in that case the scroll happens when the user clicks the button. In the case of the query preview it happens async, potentially a long while after clicking the button |
Not necessarily, it can also happen same way as you described with preview - you submit, data is validated async on API, API is slow, you get response after same 7 seconds. |
I'd consider that a flawed UX. I think a user should stay in control of the scroll position. If the validation comes back async I'd consider showing a notification "x validation errors" that scrolls to the relevant field on click. One of the main tenets of user interface design, is that the user needs to feel in control, and mostly, that they are in control of their time. if we're not going to block the whole UI while preview is loading, then we shouldn't manipulate it without user action.
Nothing hypothetical about that, I do it all the time. e.g. I often realize right when I click the button that I forgot something. It's also not only editing, I may just be reading through the other tabs to see which options are available. |
cc @gerdadesign for your input about above ☝️ |
Just to note that the specific feature in question is not strictly necessary to close the ticket. Another option could be to merge without it and take our time to define the right UX. (e.g. in a follow-up issue, or RFC,...) |
@bytasv I might have not expressed myself very well, so the idea was be to merge this PR without the automatic tab switching. Or perhaps this was merged accidentally? |
return true; | ||
} | ||
|
||
return !isEmpty(data); |
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 don't think the logic is sound here. It should be perfectly valid to return empty arrays or empty objects from the transform function. Similarly, untransformedData
can perfectly return an empty array while the transformed data returns undefined
.
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.
Sorry it's not really clear what you are proposing or what's exactly the issue?
Similarly, untransformedData can perfectly return an empty array while the transformed data returns undefined.
Can you provide an example?
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.
Can you provide an example?
Sure thing, here's a transform function that legitimately returns an empty array:
use url: https://httpbin.org/json
use transform: return data.slideshow.slides.filter(slide => slide.title.includes('foo'));
I believe this should not show the warning.
I also think we should accept null
as a legitimate value and only show a warning when the transform is returning undefined
.
We should probably also make the JsonView
show undefined
instead of nothing when the input is undefined
Lastly, I believe we should also consider preventing the overuse of basic lodash
methods through no-restricted-imports
and only whitelist a few like pick
, throttle
, get
and set
. Methods like isEmpty
cover a too broad range of values and result in bugs like these. Also, the word "empty" doesn't have a well defined meaning in programming, making the code less intuitive. Better to use native constructs to express the intent clearer to other maintainers
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.
Thanks, that's great feedback, I've addressed it in a follow up PR: #1165
No, I did set this to merge as that's how I understood your comment. As for feature itself, I disagree with you, I think tab switching is a good UX in this case, just as I explained in previous comment, so I will not revert this change for now. If there is more feedback from others adding that it should not behave like that we can change it. |
About switching tabs automatically, I also don't like that type of pattern as it can be disruptive or annoying to users. |
undefined
results in fetch preview window #1083Added logic for:
transform
tab will become active