Skip to content

[Blazor] Fix WebView renderer not correctly dispatching browser events #49958

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

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Components/Web.JS/dist/Release/blazor.webview.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { DotNet } from '@microsoft/dotnet-js-interop';
import { showErrorNotification } from '../../BootErrors';
import { OutOfProcessRenderBatch } from '../../Rendering/RenderBatch/OutOfProcessRenderBatch';
import { attachRootComponentToElement, renderBatch } from '../../Rendering/Renderer';
import { setApplicationIsTerminated, tryDeserializeMessage } from './WebViewIpcCommon';
import { sendRenderCompleted } from './WebViewIpcSender';
import { internalFunctions as navigationManagerFunctions } from '../../Services/NavigationManager';
import { dispatcher } from '../../Boot.WebView';
import { WebRendererId } from '../../Rendering/WebRendererId';

export function startIpcReceiver(): void {
const messageHandlers = {

'AttachToDocument': (componentId: number, elementSelector: string) => {
attachRootComponentToElement(elementSelector, componentId);
attachRootComponentToElement(elementSelector, componentId, WebRendererId.WebView);
},

'RenderBatch': (batchId: number, batchDataBase64: string) => {
try {
const batchData = base64ToArrayBuffer(batchDataBase64);
renderBatch(0, new OutOfProcessRenderBatch(batchData));
renderBatch(WebRendererId.WebView, new OutOfProcessRenderBatch(batchData));
sendRenderCompleted(batchId, null);
} catch (ex) {
sendRenderCompleted(batchId, (ex as Error).toString());
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Web.JS/src/Rendering/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function attachRootComponentToLogicalElement(browserRendererId: number, l
browserRenderer.attachRootComponentToLogicalElement(componentId, logicalElement, appendContent);
}

export function attachRootComponentToElement(elementSelector: string, componentId: number, browserRendererId?: number): void {
export function attachRootComponentToElement(elementSelector: string, componentId: number, browserRendererId: number): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since browserRenderId is now required could the fallback to 0 in line 47 be removed?
browserRendererId || 0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it could be. I can remove it the next time I touch this area, but feel free to open a PR if you feel inclined :)

const afterElementSelector = '::after';
const beforeElementSelector = '::before';
let appendContent = false;
Expand Down