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

chore: avoid button 'flickering' during extension start #6863

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

Conversation

deboer-tim
Copy link
Collaborator

What does this PR do?

Minor fix: to stop the extension buttons from 'flickering' during start, switch the start button enablement to !started. This ensures that there is always one button visible (start or stop) so nothing 'moves'.

Screenshot / video of UI

N/A, hard to catch flickering on video.

What issues does this PR fix or reference?

One part of #6855.

How to test this PR?

Stop and start an extension multiple times and ensure the buttons in that row don't move.

To stop the buttons from 'flickering' during start, switch the start button
enablement to !started. This ensures that there is always one button
visible (start or stop) so nothing 'moves'.

One part of containers#6855.

Signed-off-by: Tim deBoer <[email protected]>
@deboer-tim deboer-tim requested review from benoitf and a team as code owners April 22, 2024 20:51
@deboer-tim deboer-tim requested review from dgolovin and axel7083 and removed request for a team April 22, 2024 20:51
@@ -16,7 +16,7 @@ async function startExtension(): Promise<void> {
}
</script>

{#if extension.state === 'stopped'}
{#if extension.state !== 'started'}
Copy link
Collaborator

Choose a reason for hiding this comment

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

it feels strange to see the start button if the state is not started.
let say state is 'unknown' or 'deleted' or something different we could see the button and this is not expected

probably need to tweak the accepted state including the starting or other intermediate steps

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The start/stop buttons already correctly enable/disable when they are not applicable, i.e. we could show both of them always and the page works fine. It is only our choice to only display one at a time to save space/reduce clutter, and flickering occurs because there are intermediate states where we have no button and so the layout adjusts.

This change is identical to what we did in the containers view, just making sure that the button visibility states are completely opposite so that you always & only see one button:

hidden="{container.state === 'RUNNING' || container.state === 'STOPPING'}"
. Neither button is enabled in these states, i.e. we could do the opposite change to the stop button.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is only our choice to only display one at a time to save space/reduce clutter,

to clarify, it's the person that did the mockup choice ;-)

and flickering occurs because there are intermediate states where we have no button and so the layout adjusts.

I understand the problem but I would avoid the usage of saying 'anything that is not started' to display the start button as while it does the trick currently, it does not guarantee it will always work as it can have side effects with the button 'stop' being displayed in some state that should not permit that.

so I would list there the states that are allowed (including the intermediate states) so it's clear that it will always be displayed for the states that we want/list and not something that may work but is fragile

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to clarify, it's the person that did the mockup choice ;-)

;-)

I understand the problem but I would avoid the usage of saying 'anything that is not started' to display the start button as while it does the trick currently, it does not guarantee it will always work as it can have side effects with the button 'stop' being displayed in some state that should not permit that.

so I would list there the states that are allowed (including the intermediate states) so it's clear that it will always be displayed for the states that we want/list and not something that may work but is fragile

We are missing tests for LoadingIconButton, but that is where we should really be verifying correct enablement of the buttons with different states. The Resources page has start/stop/restart all visible so that will help too.

Which means that the fragile part here is mostly just ensuring that if state === x and if state != x are exactly opposite between these two buttons and only one appears. In ContainerActions that's obvious enough because they're 9 lines apart, but not here. So, I've added tests to the lifecycle component that cover both which buttons appear in each state and enablement, let me know what you think.

Copy link
Collaborator

Choose a reason for hiding this comment

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

the condition is still erroneous to me. We can't hide a start button if we're in a state different than 'started'. This is semantically incorrect and it can lead to errors

If you prefer as you're telling that the LoadingIconButton is already smart. It's to add a property to this component so it'll hide if condition is not satisfied as well.

so instead of doing the if there, it's done inside the component that will control its display usage

Either it includes all the valid states where it should be displayed or it's inside the LoadingIconButton component as well but it should still use states semantically valid.

Add tests to ensure correct button visibility and enablement in each of the
extension states.

Signed-off-by: Tim deBoer <[email protected]>
benoitf added a commit to benoitf/desktop that referenced this pull request Apr 25, 2024
benoitf added a commit that referenced this pull request Apr 25, 2024
might be related to #6863
Signed-off-by: Florent Benoit <[email protected]>
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.

None yet

2 participants