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

fix: render Ordertab only when it is active #6583

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

Conversation

Abhishek-17h
Copy link
Contributor


The video showcases the behavior after the fix:
Screencast from 2025-01-13 09-17-05.webm

Closes #6492

Copy link

netlify bot commented Jan 13, 2025

Deploy Preview for plone-components canceled.

Name Link
🔨 Latest commit d51ccff
🔍 Latest deploy log https://app.netlify.com/sites/plone-components/deploys/67ac1412a9849e00084fe137

@Abhishek-17h
Copy link
Contributor Author

@stevepiercy @ichim-david @davisagli Please provide review.

Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

Minor change in the change log entry.

packages/volto/news/6492.bugfix Outdated Show resolved Hide resolved
@stevepiercy
Copy link
Collaborator

This is a nice step forward. Thanks for your work on this.

In the video, I noticed two things that I'd like to ask for opinions from the members of both the @plone/volto-accessibility and @plone/volto-team. Please don't make changes yet, but let's get some feedback.

  1. When the Order tab gets activated, there is a slight delay of about a half-second with a "no entry" icon 🚫 displayed. Should that be changed to a "Loading" icon? When editing a page or control panel, then click Save, I see the loading class injected into the Save button and a grey spinning circular line.
  2. I don't think the Order list items should unload when the Order tab gets deactivated after it was active one time. I think it should remain loaded, but hidden. That will eliminate second and subsequent reloads while editing a given page.

@Abhishek-17h
Copy link
Contributor Author

Thank you, @stevepiercy, for your suggestions.

I completely agree with your first suggestion regarding replacing the icon 🚫 with a "Loading" icon. In fact, I had initially considered implementing this change before raising the PR but decided to keep the existing behavior to gather feedback from the Volto team and accessibility experts. It's great to see that you noticed it too, as it reinforces the need for improvement in this area.

Regarding your second suggestion, I think it’s a great idea, but I am concerned that its implementation might conflict with the main issue being addressed.

Looking forward to hearing more thoughts from the Volto team and accessibility members on these points!

@ichim-david ichim-david changed the title fix: render Ordertab only when iti is active fix: render Ordertab only when it is active Jan 13, 2025
@ichim-david ichim-david self-requested a review January 13, 2025 08:04
@Abhishek-17h Abhishek-17h force-pushed the bugfix/render-order-panel-on-active branch 2 times, most recently from bc449af to 8e02a2c Compare January 18, 2025 09:30
@Abhishek-17h
Copy link
Contributor Author

@ichim-david please provide review on this.

@ichim-david
Copy link
Member

@Abhishek-17h technically speaking what you did is what I've asked.

The problem is that the UX isn't very good as it takes a long time to load even locally with a very fast MacBook pro.
I made a video where I compared the before and after and mentioned a few things that I would still play with.
https://www.youtube.com/watch?v=IFaCNBAGshE
The TLDR is:

  • we need a loading indicator as that round circle cut in half is the icon usually used to denote that the block doesn't have any block options.

See if you can introduce a loader to give some info to the user that the panel is loading. I would also try to look at the logic of the component and try to understand why it takes so long to load and if there is anything that can be done to speed it up.

If we were to simply merge this change it would be a degradation of service of the order tab for the editor on account on having to wait so long to interact with it, especially on second time interactions on the same page.

@Abhishek-17h
Copy link
Contributor Author

@ichim-david, I have watched your testing video and truly appreciate the time you took to explain everything in detail. I will implement the things you mentioned. Thank you for your guidance!

@Abhishek-17h Abhishek-17h force-pushed the bugfix/render-order-panel-on-active branch 2 times, most recently from f8272ca to 7b06c00 Compare January 19, 2025 13:43
@Abhishek-17h
Copy link
Contributor Author

@ichim-david have a look now.
Made two changes:
1)Added loader svg for order tab instead of forbidden svg and please check size of loader as I declared size which looked perfect to me.
2)Order tab now renders on first time and remain rendered .By doing this user don't have to wait every time for order tab to render and it is better than previous behaviour.

Ref Video:
Screencast from 2025-01-19 19-07-13.webm

I don't think we can speed up the rendering of the order tab if we only want to render it when it's active. I've tried many things but haven't had any success.
The changes that I made looks best to me than existing one.
Waiting for your response.

@Abhishek-17h
Copy link
Contributor Author

@stevepiercy give your feedback also on this.

@Abhishek-17h Abhishek-17h force-pushed the bugfix/render-order-panel-on-active branch from 2c2e121 to df5b566 Compare January 20, 2025 15:24
@stevepiercy
Copy link
Collaborator

The animated loading icon looks much better.

There are two rendering times: (1) that which the user perceives, and (2) that which is the actual render time after the page is loaded in edit mode, and then the editor clicks the Order tab.

To reduce option 1 time, we can pre-load option 2. But that would defeat the purpose of this PR and original issue.

I have no idea how to improve option 2. Its slow render time only became apparent after work on this PR was started.

At this point, we have a trade-off between either having a quick initial Order tab experience or waiting to initially render the Order tab only when it's active. I don't see the advantage of degrading the editor experience.

@ichim-david what is the actual problem with rendering the Order tab when it is not active? Yes, it shows up in Developer Tools, but why is that a bad thing?

@sneridagh
Copy link
Member

@ichim-david honestly, do you think that this is the way of fixing this one, or we should look into a much deeper fix, fixing the updates on components as we talked some time ago? Maybe we should also put @robgietema in the loop.

@ichim-david
Copy link
Member

@ichim-david honestly, do you think that this is the way of fixing this one, or we should look into a much deeper fix, fixing the updates on components as we talked some time ago? Maybe we should also put @robgietema in the loop.

The animated loading icon looks much better.

There are two rendering times: (1) that which the user perceives, and (2) that which is the actual render time after the page is loaded in edit mode, and then the editor clicks the Order tab.

To reduce option 1 time, we can pre-load option 2. But that would defeat the purpose of this PR and original issue.

I have no idea how to improve option 2. Its slow render time only became apparent after work on this PR was started.

At this point, we have a trade-off between either having a quick initial Order tab experience or waiting to initially render the Order tab only when it's active. I don't see the advantage of degrading the editor experience.

@ichim-david what is the actual problem with rendering the Order tab when it is not active? Yes, it shows up in Developer Tools, but why is that a bad thing?

@stevepiercy The problem is that we render another set of drag and drop block clones which re-render on any of the block changes. And this is happening even when the order tab isn't focused and in a page with many blocks and with many text editors it can introduce a performance problem since you start typing and for each character, all of the blocks are re-rendered. Once in the main area and the second time in the order tab area.

If we have the order tab rendered only when we actually interact with it, and then we drag and drop the blocks We avoid this extra performance overhead.

@sneridagh Since it's not an easy thing to fix I think having the order block rendered only when we interact with it is a good workaround until we are able to make both the inline area and the order area less reactive to a block change which re-renders all of the blocks since it's part of the same drag and drop area.

I would also add a setting in the config enabled by default to render the order allowing this feature to also be turned off if someone doesn't want it.

@stevepiercy
Copy link
Collaborator

@ichim-david thanks for the explanation. I'm surprised to learn that the Order items render for every keystroke while editing inside a block, and not only when drag-and-dropping. I assumed it happened only when drag-and-dropping. Is there a purpose for rendering on every keystroke?

I also like your suggestion of making it a configurable setting that editors may opt-in to, perhaps explaining the trade-off, until we can optimize the render function. We should explain the trade-offs in the setting UI, of course, and name it well.

@ichim-david
Copy link
Member

@stevepiercy have a look at this video, I started without audio but after the 1 min mark I also started saying something.
This makes it even more obvious why I am insisting on rendering this order tab only when it's focused.

volto-re-rendering.mp4

@robgietema
Copy link
Member

LGTM

@sneridagh sneridagh requested review from davisagli, pnicolli and a team February 7, 2025 19:19
@sneridagh
Copy link
Member

@plone/volto-team Can I have a final look and nod for this one, please? Thanks!

@ichim-david @stevepiercy all settled on this one?

@Abhishek-17h Abhishek-17h force-pushed the bugfix/render-order-panel-on-active branch from 008ab55 to b829d36 Compare February 11, 2025 18:06
@@ -57,6 +58,7 @@ const Sidebar = (props) => {
);
const [size] = useState(0);
const [showFull, setshowFull] = useState(true);
const [isOrderTabRendered, setIsOrderTabRendered] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like it can cause unnecessary rerenders. The active index tab is an information we already have two lines below with the tab variable. In other words, isOrderTabRendered can simply be something like this, moved after const tab = ...

  const isOrderTabRendered = tab === 2;

Is this state needed for some other case I might be missing at this time?

Comment on lines +107 to +109
if (data.activeIndex === 2) {
setIsOrderTabRendered(true);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If my assumptions above are correct, this should be removed

</Tab.Pane>
),
pane:
isOrderTabRendered || tab === 2 ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

If my assumptions above are correct, this can simply be

Suggested change
isOrderTabRendered || tab === 2 ? (
tab === 2 ? (

Copy link
Contributor

Choose a reason for hiding this comment

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

@plone/volto-team don't we have any solution already for loading spinners?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, but I don't know where in the code base. Image upload uses it.

Screen.Recording.2025-02-11.at.3.55.18.PM.mov

@stevepiercy
Copy link
Collaborator

@ichim-david @stevepiercy all settled on this one?

I'm OK with it, provided @ichim-david is satisfied, and we create a new issue to capture the future improvements, if y'all agree, specifically:

  • Make both the inline area and the order area less reactive to a block change, which re-renders all of the blocks since it's part of the same drag and drop area.
  • Add a setting in the configuration enabled by default to render the order, allowing this feature to be turned off if someone doesn't want it.
  • Document both the above.

@Abhishek-17h
Copy link
Contributor Author

@pnicolli You are right , and I done the same when I raise this PR but it takes so much time to render order tab even though activeIndex==2 mentioned in this video. That's why I introduced a state variable which tracks activeIndex and ensure that order tab remains rendered after initial load.

The video showcases the behavior after the fix: Screencast from 2025-01-13 09-17-05.webm

Closes #6492

New behaviour is mentioned in this video

@ichim-david have a look now. Made two changes: 1)Added loader svg for order tab instead of forbidden svg and please check size of loader as I declared size which looked perfect to me. 2)Order tab now renders on first time and remain rendered .By doing this user don't have to wait every time for order tab to render and it is better than previous behaviour.

Ref Video: Screencast from 2025-01-19 19-07-13.webm

I don't think we can speed up the rendering of the order tab if we only want to render it when it's active. I've tried many things but haven't had any success. The changes that I made looks best to me than existing one. Waiting for your response.

@Abhishek-17h Abhishek-17h force-pushed the bugfix/render-order-panel-on-active branch from b829d36 to d51ccff Compare February 12, 2025 03:22
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.

Order layout panel should be enabled only when we are focused on that panel
6 participants