Automattic / sensei

Sensei LMS - Online Courses, Quizzes, & Learning
https://senseilms.com
GNU General Public License v2.0
543 stars 197 forks source link

Editor saves too many times when saving lessons from the Course Outline block #7334

Open donnapep opened 11 months ago

donnapep commented 11 months ago

Steps to Reproduce

  1. Create a new course.
  2. In the Course Outline block, click Save to edit lesson from the toolbar.

What I Expected

The editor to save once.

What Happened Instead

The editor appears to be saving multiple times, probably once per lesson.

Screenshot / Video

https://github.com/Automattic/sensei/assets/1190420/25834d0d-9d7d-4f33-a4f0-ced58d872443

renatho commented 11 months ago

In a quick test, I tried to add many lessons to a course, and it didn't increase the number of savings.

IIRC, it should save 2 times only:

So I'm not sure why we have 3 saves. The reference where it's probably happening is here: assets/shared/structure/structure-store.js.

If it's helpful, at some point I wrote assets/shared/helpers/editor-lifecycle.js, which could be useful in a refactor to simplify the subscribeToPostSave.