fix(module:overlay): getFirstChildDomInfo will return passed dom instead of body when no child element exists #989
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.
🤔 This is a ...
🔗 Related issue link
#873
💡 Background and solution
The bug was appearing in
Dropdown
whenChildContent
was not an element but a simple text:Here, "Dropdown" is not an element. If it was wrapped in (for example)
<span>
, this bug would not surface.The problem here is that the underlying
Overlay
is trying to get Childcontent's first child. By default with current approach child content is wrapped in adiv
- soOverlay
will try to getdiv
's first child. If there is no element inside (for "Dropdown" there is no element), theOverlay
will be delivered<body>
element.The fix is to check if first child is null and when it is, then just return the passed element (for that issue it will be
div
).Possible issues
This is a quick fix. The
getFirstChildDomInfo
is only used byOverlay
andOverlayTrigger
. It does not really return what it promises based on its name. Currently it either returns (correctly) first child of the passed dom element or top parent (<body>
). With this PR, it will either return first child of the passed dom element or the dom element itself. It probably should return null, but that would require much more code changes. The possible issues comes from naming - what will a consumer expect and how will current/proposed resolution match/miss consumer's expectations.📝 Changelog
☑️ Self Check before Merge