[ContextMenu][DropdownMenu] Fix issue introduced by new selector
prop
#404
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.
Closes #402
After checking a reported issue #402, I realised we have introduced a bug in dependents of
Menu
(ContextMenu
,DropdownMenu
) when we added theselector
prop.This is because the expectation on what attributes are present changed, and we didn't account for it here.
Namely, before we were expecting the
data-radix-menu-item
to be present even in dependents ofMenu
.This is no longer a safe assumption to make obviously, therefore we cannot rely on this selector.
Looking at other places we build selectors like this (roving focus behaviour, or typeahead behaviour) they both add their own data attribute to ensure they can safely select items. So it seems in this case we should be doing the same somehow. It feels a bit more annoying given that we know there is already a default selectors for items… but obviously now specific to each dependent of
Menu
).I haven't made any change yet, wondering what your thoughts were.