-
Notifications
You must be signed in to change notification settings - Fork 18
Bug: Highlighting not working with embedded LiveViews #797
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
base: main
Are you sure you want to change the base?
Bug: Highlighting not working with embedded LiveViews #797
Conversation
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.
Nice!
assets/client/utils/meta.js
Outdated
|
||
const observer = new MutationObserver((mutations) => { | ||
mutations.forEach((mutation) => { | ||
console.log('mutation'); |
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.
is this needed?
assets/client/utils/meta.js
Outdated
if ( | ||
mutation.type === 'attributes' && | ||
mutation.attributeName === 'data-phx-root-id' | ||
) { |
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.
Nitpick: how about early return?
assets/client/utils/meta.js
Outdated
if (Object.keys(rootIDs).length >= liveViewElements.length) { | ||
const rootSocketIDs = new Set(Object.values(rootIDs)); | ||
rootSocketIDs.delete(mainID); | ||
|
||
observer.disconnect(); | ||
|
||
resolve({ | ||
mainSocketID: mainID, | ||
rootSocketIDs: [...rootSocketIDs], | ||
}); | ||
} |
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.
Could you please split it to a function and name it so that it will be easier to understand what is happening here?
The problem is that debugger connect to the client via websocket using single root socket id but when dealing with "embedded" LiveViews there is more than one.
Solution I came up with:
socket_id
of regular LiveView (it's the only LiveView ontransport_pid
that is neitherembedded
nornested
)Also fixes #723