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

Deletion of menu items on the Navigation screen. #21282

Closed
talldan opened this issue Mar 31, 2020 · 3 comments
Closed

Deletion of menu items on the Navigation screen. #21282

talldan opened this issue Mar 31, 2020 · 3 comments
Assignees
Labels
[Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@talldan
Copy link
Contributor

talldan commented Mar 31, 2020

Is your feature request related to a problem? Please describe.
#21036 implemented the experimental nav screen. Currently menu items can be added or modified, but can't be removed.

Describe the solution you'd like
In addition to get and save functions, the core data package also exposes a remove/delete function for entities. This is used to allow the deletion of menu items in this code:

@talldan talldan added [Type] Enhancement A suggestion for improvement. [Block] Navigation Affects the Navigation Block labels Mar 31, 2020
@draganescu draganescu assigned draganescu and unassigned draganescu Apr 1, 2020
@draganescu draganescu self-assigned this Apr 12, 2020
@draganescu
Copy link
Contributor

This is a bit complicated by the fact that the menu items which the useNavigationBlocks hook gets and serves up to it's calee's are not connected by any value to the menu items in the DB (ideally this should be by ID).

One reason for this is that in the navigation link block the concept of ID is completely different and refers to the id of the post linked to. In the context of menu items ID is the menu item's entry number in the wp_postmeta.

Since useNavigationBlocks artificially creates innerBlocks out of menu items we could:

  1. reuse the id attribute of navigationLink in this context to mean something else
  2. add a new attribute to navigationLink that is only used in this context

I try to use (1) since the two contexts are not likely to be interchangeable.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Apr 13, 2020
@noisysocks noisysocks added the [Priority] High Used to indicate top priority items that need quick attention label Apr 15, 2020
@noisysocks noisysocks removed the [Priority] High Used to indicate top priority items that need quick attention label Apr 26, 2020
@draganescu
Copy link
Contributor

draganescu commented May 15, 2020

Later edit

Apparently invalidateCache:true in the delete action caused the issue.

Problem description Eventually, the problem we hit here is about the entities system not supporting `delete` operations on `Entity` data. We went ahead and tried different approaches to implement delete (with and without undo) but we have uncovered something which appears to be a bug in the Entities system, explained briefly like this:

image

There is something that calls receiveEntityRecords after the delete flow has completed. This causes that in effect:

  1. The items get deleted from the DB by the apiFetch call
  2. The items get removed from the state by the REMOVE_ITEMS action in the items reducer
  3. The items appear back in the state by some mysterious call to receiveEntityRecords

Step 3 is done through some auto-magic wiring between apiFetch or getEntityRecords and the state. It is weird and unexpected.

@draganescu
Copy link
Contributor

#22603 closed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants