Skip to content

fix: Rename optimistic update in children containers - #2141

Merged
ChrisChV merged 14 commits into
openedx:masterfrom
open-craft:chris/FAL-4165-fix-name-update
Jun 19, 2025
Merged

fix: Rename optimistic update in children containers#2141
ChrisChV merged 14 commits into
openedx:masterfrom
open-craft:chris/FAL-4165-fix-name-update

Conversation

@ChrisChV

Copy link
Copy Markdown
Contributor

Description

  • When you update the title of a unit/subsection in the subsection/section page, the text returns to the previous value for a while. This PR fix that issue
  • Which edX user roles will this change impact? "Course Author.

Supporting information

Testing instructions

  • Go to the library home of a library
  • Create one unit, one subsection and one section.
  • Add the unit to the subsection.
  • Add the subsection to the section.
  • On the section page, rename the subsection, verify that the optimistic update works.
  • On the subsection page, rename the unit, verify that the optimistic update works.

Other information

  • Fixing this issue results in an increase in requests, but the user is not affected for the use of placeHolderText

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jun 12, 2025
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @ChrisChV!

This repository is currently maintained by @bradenmacdonald.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@bradenmacdonald

Copy link
Copy Markdown
Contributor

@ChrisChV let me know when you've fixed the cyclic import test error, and then I can test and review.

@codecov

codecov Bot commented Jun 12, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.09%. Comparing base (08c3d12) to head (4b51703).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2141      +/-   ##
==========================================
- Coverage   94.10%   94.09%   -0.01%     
==========================================
  Files        1164     1164              
  Lines       24495    24507      +12     
  Branches     5310     5201     -109     
==========================================
+ Hits        23050    23060      +10     
- Misses       1377     1379       +2     
  Partials       68       68              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ChrisChV

Copy link
Copy Markdown
Contributor Author

know when you've fixed the cyclic import test error, and then I can test and review.

@bradenmacdonald Done!

@bradenmacdonald

Copy link
Copy Markdown
Contributor

@ChrisChV It's mostly working, but I'm still seeing a weird flash of the old name for a second.

optimistic.error.mov

@ChrisChV

Copy link
Copy Markdown
Contributor Author

@bradenmacdonald I tried it again, and I don't see the flash. But it has happened to me that I have had to start my tutor again after changing branches. Can you try that to see if the flickering continues?

https://www.loom.com/share/c221323489574697ab20937065ef2b0d?sid=f9cac243-41c4-4185-a547-4c3ab310b79f

@bradenmacdonald

Copy link
Copy Markdown
Contributor

@ChrisChV Weird. I restarted and rebuilt everything and it was still happening. Then I tried making some changes and now it's working! Not really sure what's going on.

Comment on lines +13 to +17
// In some cases, the title is already available, but it's retrieved in a list of containers.
// In these cases, it's necessary to use this `ContainerEditableTitle` for the optimistic update to work.
// By using `placeHolderText`, we can give the illusion that the data
// has already been loaded before using the real data.
placeHolderText?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't really understand why we need this.
When I removed it in 8576925 and tested, it's still working fine (the optimistic update works without it).

it's retrieved in a list of containers.

Where is that happening? Before you added this placeHolderText, the only place I see this component getting the title from is useContainer(containerId) which is not a list of containers. Maybe we should be getting it from a list though, as it may be a little inefficient loading each container separately if there's a lot in the parent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Where is that happening?

In LibraryContainerChildren, you get the containers in a list using useContainerChildren

The optimistic update is implemented by overwriting the data of the useContainer query. I feel like doing the same for the useContainerChildren query is going to be more complicated.

as it may be a little inefficient loading each container separately if there's a lot in the parent

This is seen visually if we do not use the placeHolderText:

https://www.loom.com/share/0090987109b44902809f55b15271090d?sid=3666ee1c-02e1-4655-8713-d3aca877454e

If you'd like, I can try implementing an optimistic update overriding useContainerChildren. This problem also exists in the component listing on the unit page, it is a separate implementation, but follows the same logic.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you'd like, I can try implementing an optimistic update overriding useContainerChildren. This problem also exists in the component listing on the unit page, it is a separate implementation, but follows the same logic.

I think that would be better if you don't mind giving it a try!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It works! It's ready for a review

@bradenmacdonald

Copy link
Copy Markdown
Contributor

I also found an annoying bug: if you are editing a title and you double-click in the input field, to select text, it cancels the edit and opens the child container instead.

Screen.Recording.2025-06-18.at.11.56.12.AM.mov

@ChrisChV

Copy link
Copy Markdown
Contributor Author

I also found an annoying bug: if you are editing a title and you double-click in the input field, to select text, it cancels the edit and opens the child container instead.

Screen.Recording.2025-06-18.at.11.56.12.AM.mov

Fixed: 78dc044

@ChrisChV
ChrisChV requested a review from bradenmacdonald June 19, 2025 00:59

@bradenmacdonald bradenmacdonald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great job! I like this approach more. Thanks for refactoring. I tested and it's working well now.

Please just add a comment, and also before merging please rebase or merge master and then manually test, just to make sure it's working OK with the Paragon 23 changes on master.

* Use this mutation to update the fields of a container in a library
*/
export const useUpdateContainer = (containerId: string) => {
export const useUpdateContainer = (containerId: string, affectedParentContainerId?: string) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please just update the JSDoc comment about to explain what the new affectedParentContainerId parameter is doing exactly?

@ChrisChV
ChrisChV merged commit 75ea750 into openedx:master Jun 19, 2025
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in Contributions Jun 19, 2025
@ChrisChV
ChrisChV deleted the chris/FAL-4165-fix-name-update branch June 19, 2025 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants