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

Story Editor: Preset Panel Height & Collapse Persistence #4601

Merged
merged 11 commits into from
Sep 22, 2020

Conversation

maxyinger
Copy link
Contributor

@maxyinger maxyinger commented Sep 21, 2020

Summary

Persists height and collapsed state of all panels in story editor. Panels should remain collapse & height between reloads, element selection & switching stories now.

Relevant Technical Choices

Persisted all panels height & collapsed state.

To-do

NA

User-facing changes

collapse/height state changes to all panels should now maintain between any actions in the editor.

Testing Instructions

Go to edit a story.

  • Click on an item & resize color preset panel. Click off that item so all panels disappear. Click back on the item and see that the color preset panel height is the same.
  • Repeat these steps checking if collapse state maintains
  • Repeat these steps but reload you page between checks
  • See that other than this, design panels still behave as expected with respect to resize/collapse behavior.

Partially fixes #825

@google-cla google-cla bot added the cla: yes label Sep 21, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Sep 21, 2020

Size Change: +3.73 kB (0%)

Total Size: 1.28 MB

Filename Size Change
assets/js/edit-story.js 504 kB +397 B (0%)
assets/js/stories-dashboard.js 599 kB +337 B (0%)
assets/js/web-stories-activation-notice.js 74 kB +2.99 kB (4%)
ℹ️ View Unchanged
Filename Size Change
assets/css/edit-story.css 909 B 0 B
assets/css/stories-dashboard.css 939 B 0 B
assets/css/web-stories-embed-block.css 515 B 0 B
assets/js/chunk-web-stories-template-0-********************.js 10.2 kB 0 B
assets/js/chunk-web-stories-template-1-********************.js 10.2 kB 0 B
assets/js/chunk-web-stories-template-2-********************.js 9.97 kB 0 B
assets/js/chunk-web-stories-template-3-********************.js 10.5 kB 0 B
assets/js/chunk-web-stories-template-4-********************.js 10.6 kB 0 B
assets/js/chunk-web-stories-template-5-********************.js 6.83 kB 0 B
assets/js/chunk-web-stories-template-6-********************.js 9.87 kB 0 B
assets/js/chunk-web-stories-template-7-********************.js 9.75 kB 0 B
assets/js/chunk-web-stories-textset-0-********************.js 1.63 kB 0 B
assets/js/web-stories-embed-block.js 17.5 kB 0 B

compressed-size-action

@carloskelly13
Copy link
Contributor

@swissspidy Should we allow a partial panel open like this or size it to the closest color swatch? Doesn't have to be part of this PR, but from a UX standpoint this feels odd. At least for the first row.

Screen Shot 2020-09-21 at 2 29 35 PM

Copy link
Contributor

@carloskelly13 carloskelly13 left a comment

Choose a reason for hiding this comment

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

This works well. Tested both the sizing of the saved presets and then the collapse states of the other design panels too.

Copy link
Contributor

@barklund barklund left a comment

Choose a reason for hiding this comment

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

Looks good, just a few minor comments.

assets/src/edit-story/components/panels/panel/panel.js Outdated Show resolved Hide resolved
assets/src/edit-story/components/panels/panel/panel.js Outdated Show resolved Hide resolved
@@ -35,6 +35,9 @@ describe('Panel: Style Presets', () => {
};

beforeEach(async () => {
// Make sure panels are starting at initial state on every test
localStorage.clear();
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, this should probably go in some global reset. @swissspidy, suggestions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea let me know here. I'm not the most familiar with the Karma tests, but think this was causing the main issue

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah probably. karma/fixture/init.js has similar resets already.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can be done in a follow-up ticket / PR too, FWIW

@swissspidy
Copy link
Collaborator

@swissspidy Should we allow a partial panel open like this or size it to the closest color swatch? Doesn't have to be part of this PR, but from a UX standpoint this feels odd. At least for the first row.

Screen Shot 2020-09-21 at 2 29 35 PM

@carlos-kelly Good catch! Sounds like an odd thing to allow. There's probably some UX definition for this already. I suggest opening an issue and tagging Sam there.

@codecov
Copy link

codecov bot commented Sep 21, 2020

Codecov Report

Merging #4601 into main will increase coverage by 13.22%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #4601       +/-   ##
===========================================
+ Coverage   70.10%   83.33%   +13.22%     
===========================================
  Files         881      881               
  Lines       15519    15444       -75     
===========================================
+ Hits        10880    12870     +1990     
+ Misses       4639     2574     -2065     
Flag Coverage Δ
#karmatests 72.42% <ø> (+42.09%) ⬆️
#unittests 66.30% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ts/src/edit-story/components/panels/panel/panel.js 81.96% <ø> (+12.57%) ⬆️
...edit-story/components/panels/preset/presetPanel.js 95.00% <ø> (+5.00%) ⬆️
assets/src/edit-story/constants.js 100.00% <ø> (ø)
assets/src/activation-notice/theme.js 66.66% <0.00%> (-13.34%) ⬇️
includes/Demo_Content.php 80.85% <0.00%> (-3.08%) ⬇️
...sets/src/activation-notice/app/components/step2.js 85.71% <0.00%> (-1.79%) ⬇️
...sets/src/activation-notice/app/components/step3.js 85.71% <0.00%> (-1.79%) ⬇️
assets/src/dashboard/app/views/toaster/index.js 75.00% <0.00%> (-1.48%) ⬇️
...sets/src/activation-notice/app/components/step1.js 87.50% <0.00%> (-1.39%) ⬇️
includes/Experiments.php 97.50% <0.00%> (-0.99%) ⬇️
... and 229 more

… in fixture. leaving in beforeEach for now
@pbakaus
Copy link
Contributor

pbakaus commented Sep 22, 2020

OMG amazing. Thank you!

@miina
Copy link
Contributor

miina commented Sep 22, 2020

For considering later:
In case of presets, it might be good to reset the panel height if all the presets are removed meanwhile. Otherwise, a previous (and now emptied) panel setting could leave unexpected room, e.g.
panels

);
parsed = JSON.parse(stored);
} catch (e) {
// @TODO Add some error handling.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm setInitialBannerPreviouslyClosed in useTelemetryOptIn should probably also wrap this in a try/catch

cc @dmmulroy

Copy link
Contributor

@dmmulroy dmmulroy Sep 22, 2020

Choose a reason for hiding this comment

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

I have no problem updating it, but what error is this catching? It seems like exceptions can be potentially thrown if the user has prevented a site from using Storage APIs, but none of our other localstorage uses are wrapped in try/catch (see just below). Should we mandate that all localstorage access be wrapped, or a utility to check for access prior to using it?

Also, what is the second argument to getItem? AFAIK it only accepts one and it will already return null by default if a key does not exists which is fine to pass to JSON.parse

@swissspidy
Copy link
Collaborator

@littlemilkstudio Looking at the Percy screenshots the default size for the layer panel seems to have changed.

Left is before, right is after:

Screenshot 2020-09-22 at 15 54 32

See how the background layer item disappears.

It's even more obvious when editing a template:

Screenshot 2020-09-22 at 15 55 18

Can you double check that?

Copy link
Contributor

@dmmulroy dmmulroy left a comment

Choose a reason for hiding this comment

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

This works for me!

@dmmulroy
Copy link
Contributor

This works for me!

Just saw Pascal's comment about default size of the lay panel, once that's good I'm good with this 👍

@maxyinger
Copy link
Contributor Author

@littlemilkstudio Looking at the Percy screenshots the default size for the layer panel seems to have changed.

Left is before, right is after:

Screenshot 2020-09-22 at 15 54 32

See how the background layer item disappears.

It's even more obvious when editing a template:

Screenshot 2020-09-22 at 15 55 18

Can you double check that?

Ahh yea, I think Percy has the value persisted between tests. Must have a test on a story where there's only 1 layer initially, so these steps follow:

  • Open story with 1 layer
  • uses min of layers or 6 which is 1 layer here to compute initial height
  • height gets set to persist
  • open new story with 6 layers, initialHeight is ignored and goes with persisted height from earlier

Updated the behavior to now only cache the state values if the user has interacted with the panel. So it shouldn't persist until the user either adjusts height of the panel or collapses it. This implementation certainly comes with it's edge cases, but this is some UX we should fine tune for a later release and just include this simpler behavior for now imo

@maxyinger maxyinger merged commit 765c6c8 into main Sep 22, 2020
@maxyinger maxyinger deleted the 825-persist-UI-state branch September 22, 2020 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI settings don't persist between reloads
7 participants