-
Notifications
You must be signed in to change notification settings - Fork 178
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
Consecutive text placement #4218
Conversation
Size Change: +1.38 kB (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
Codecov Report
@@ Coverage Diff @@
## main #4218 +/- ##
==========================================
+ Coverage 80.25% 82.87% +2.61%
==========================================
Files 824 830 +6
Lines 14334 14482 +148
==========================================
+ Hits 11504 12002 +498
+ Misses 2830 2480 -350
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
A few comments.
I don't really feel this makes the editor experience better, but if this is what UX thinks is best, I'm all for it.
Maybe I just don't understand why we don't simply stagger all texts added regardless of hierarchy.
assets/src/edit-story/components/library/panes/text/karma/textPane.karma.js
Outdated
Show resolved
Hide resolved
assets/src/edit-story/components/library/panes/text/karma/textPane.karma.js
Outdated
Show resolved
Hide resolved
assets/src/edit-story/components/library/panes/text/karma/textPane.karma.js
Outdated
Show resolved
Hide resolved
assets/src/edit-story/components/library/panes/text/textPane.js
Outdated
Show resolved
Hide resolved
assets/src/edit-story/components/library/panes/text/textPane.js
Outdated
Show resolved
Hide resolved
assets/src/edit-story/components/library/panes/text/textPane.js
Outdated
Show resolved
Hide resolved
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.
This works as expected. Just a few minor comments.
assets/src/edit-story/components/library/panes/text/textPane.js
Outdated
Show resolved
Hide resolved
if ( | ||
!lastPreset.current || | ||
versionNumber - lastPreset.current.versionNumber !== 1 | ||
) { |
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.
It's a bit tricky to rely on version number only accumulating once. For instance, auto-save will probably update history, which might conflict with this. The "good" solution would be to only set lastPreset
after the history has updated and then clear it if history updates again in-between. But with the current structure that's not really possible. We don't have a way to say "and after the next update, do this".
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.
Hmm, auto-save/save shouldn't really update the version number/history though -- it should only update the saved version number. If auto-save (or save) does that then there's an issue with history, perhaps related to #4094
versionNumber - lastPreset.current.versionNumber !== 1
is actually the check to see if the history has updated meanwhile -- in any other case then the difference being 1
something other than adding a preset has happened.
Just tested that currently saving the story seems to modify the history indeed (e.g. saving and then clicking Undo does nothing, indicating that the save itself has modified something) -- this would need investigation, will add a note to #4094.
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.
Changed the logic a bit in 1704efb -- let me know if it's a bit more clear now. However, note that due to the history bug it still stops the consecutive ordering when saving/auto-saving. 🤷
I think we can live with that until the history bug gets fixed though. Debugged it a bit and saving, or loading a new story indeed seems to create a new (identical to the previous) history entry into history -- perhaps there's object mutation happening somewhere instead of returning the original object.
Thoughts?
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 think the new structure works well.
The "bug" is due to us post-save updating the story with the correct link and status of the story - e.g. if the user has changed permalink settings since last saving, the permalink will come back changed when saving is complete.
The bug could then be considered that history is reported as changed, even though no attribute actually updated. But saving can and should be able to update the story and thus progress history, due to the above possible changes happening outside the editor.
assets/src/edit-story/components/library/panes/text/karma/textPane.karma.js
Outdated
Show resolved
Hide resolved
await fixture.events.click(fixture.editor.library.text.preset('Paragraph')); | ||
await fixture.events.click(fixture.editor.library.text.preset('OVERLINE')); |
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.
Hm, there's something fishy in the screenshot though. Overline is added to the bottom, while the paragraph wrapped up at the original starting point. Overline added last should have gone right below the last paragraph (added at the original offset).
I think the history didn't manage to update between these, which is why this can occur. It's not super critical but might make the test a bit flaky.
Maybe you should create a wrapper method that makes sure to wait for history to update before proceeding with the next text insertion.
WDYT?
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.
Hmm, looks like the issue is with the first "Heading 1" and the first "Paragraph" -- it looks like the first paragraph was added on top of Heading 1 instead of below it -- the following elements seem to be staggered correctly after that.
Indeed it looks like the history didn't update properly meanwhile -- seems to be an issue with the test only.
Will follow up on making the tests more robust in a separate PR. |
Improves flaky tests from #4218 (text staggering)
Summary
Adds logic for consecutively placing text presets.
Relevant Technical Choices
To-do
User-facing changes
Text presets are positioned if clicked on consecutively:
Testing Instructions
I
Fixes #1924