-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
List View: Ensure list view block id is unique to the list view instance #49944
Merged
andrewserong
merged 1 commit into
trunk
from
update/list-view-block-id-to-include-list-view-instance-id
Apr 20, 2023
Merged
List View: Ensure list view block id is unique to the list view instance #49944
andrewserong
merged 1 commit into
trunk
from
update/list-view-block-id-to-include-list-view-instance-id
Apr 20, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
andrewserong
added
[Type] Code Quality
Issues or PRs that relate to code quality
[Feature] List View
Menu item in the top toolbar to select blocks from a list of links.
labels
Apr 20, 2023
andrewserong
requested review from
scruffian,
getdave,
talldan,
apeatling,
ramonjd and
tellthemachines
April 20, 2023 05:39
Size Change: -10 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
ramonjd
approved these changes
Apr 20, 2023
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.
apeatling
approved these changes
Apr 20, 2023
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.
- ✅ List view still works as expected
- ✅ Confirmed I can see a 0 inserted in the id
Thanks for the reviews! |
andrewserong
deleted the
update/list-view-block-id-to-include-list-view-instance-id
branch
April 20, 2023 23:55
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Feature] List View
Menu item in the top toolbar to select blocks from a list of links.
[Type] Code Quality
Issues or PRs that relate to code quality
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Update the list view block's
id
attribute to be unique to the list view instance.Why?
When the Navigation block uses the List View in the block inspector (in #49417) there will be two instances of the list view on the same page. The current block id attribute is a string with a
clientId
appended, which likely won't be unique enough in the site editor with both the list view open and the navigation block selected.This isn't too much an issue right now, but if and when we want to use the block id to source the right element to use as the draggable chip when dragging list view items (e.g. in #49820), then we'll need to be sure that the block the user clicked on has a unique id, or the wrong element (and element position) might be cloned.
How?
useInstanceId
at the root of the list view, and add it to the list view contextuseMemo
call when defining the context. I had to removeisMounted.current
to please the linter as it said it was unnecessary. It didn't seem to cause any issues removing it, but I very well could have missed something!Testing Instructions
0
inserted in the id. E.g.list-view-0-block-43517952-45f3-4c19-8162-158f12713220
instead oflist-view-block-43517952-45f3-4c19-8162-158f12713220
.Testing Instructions for Keyboard
Screenshots or screencast
The updated markup when inspected (note the id attribute):