Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds WASM-friendly styling and initialization behavior to the PdfReader component by consolidating CSS, deferring toolbar visibility until JS initialization, and updating the JS loader to reference the new bundled stylesheet. Sequence diagram for PdfReader WASM initialization and toolbar revealsequenceDiagram
participant BlazorPdfReader as BlazorPdfReaderComponent
participant JSInterop as JSInterop
participant PdfReaderJS as PdfReaderJsModule
participant Document as Document
participant CssLink as CssLinkLoader
BlazorPdfReader->>JSInterop: invoke init(id, invoke, options)
JSInterop->>PdfReaderJS: init(id, invoke, options)
PdfReaderJS->>CssLink: addLink(./_content/BootstrapBlazor.PdfReader/css/pdf_reader.css)
CssLink-->>PdfReaderJS: css_loaded
PdfReaderJS->>Document: getElementById(id)
Document-->>PdfReaderJS: el
PdfReaderJS->>PdfReaderJS: addToolbarEventHandlers(el, pdfViewer, invoke, options)
PdfReaderJS->>Document: querySelectorAll(.invisible) on el
Document-->>PdfReaderJS: invisibleElements
PdfReaderJS->>Document: remove class invisible from toolbar, controls, pdf_info
PdfReaderJS->>BlazorPdfReader: invoke callbacks via invoke (events, status)
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Using a generic
.invisibleclass to control initial visibility may conflict with existing utility classes (e.g., Bootstrap’s.invisible) and can be brittle; consider renaming to a more specific, component-scoped class (e.g.,.bb-pdf-initially-hidden) to avoid collisions. - Hiding the toolbar and document info until JS initialization completes means users with JS disabled or with initialization errors will never see basic controls; consider providing a minimal non-JS fallback or only hiding non-critical pieces to preserve basic usability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Using a generic `.invisible` class to control initial visibility may conflict with existing utility classes (e.g., Bootstrap’s `.invisible`) and can be brittle; consider renaming to a more specific, component-scoped class (e.g., `.bb-pdf-initially-hidden`) to avoid collisions.
- Hiding the toolbar and document info until JS initialization completes means users with JS disabled or with initialization errors will never see basic controls; consider providing a minimal non-JS fallback or only hiding non-critical pieces to preserve basic usability.
## Individual Comments
### Comment 1
<location> `src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js:374-376` </location>
<code_context>
const addToolbarEventHandlers = (el, pdfViewer, invoke, options) => {
const toolbar = el.querySelector(".bb-view-toolbar");
+ [...el.querySelectorAll('.invisible')].forEach(i => {
+ i.classList.remove('invisible');
+ });
EventHandler.on(toolbar, "click", '.bb-view-bar', e => {
</code_context>
<issue_to_address>
**issue (bug_risk):** Using a blanket `.invisible` selector may unintentionally affect elements that should remain hidden or be controlled independently.
Removing `invisible` from every descendant of `el` tightly couples toolbar initialization to all other uses of that class in the component. If other elements later use `invisible` for their own lifecycle (e.g., lazy-loaded or conditional content), they’ll be incorrectly made visible here. Instead, target only the toolbar-related elements you intend to reveal, for example:
```js
['.bb-view-toolbar-main.invisible', '.bb-view-controls.invisible', '.bb-view-pdf-info.invisible']
.forEach(sel => el.querySelectorAll(sel).forEach(i => i.classList.remove('invisible')));
```
This keeps initialization scoped to the relevant UI parts and avoids side effects on unrelated elements.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
This PR adds WASM (WebAssembly) mode support to the PdfReader component by addressing CSS scoping and initialization timing issues. The changes involve removing deprecated ::deep CSS selectors, consolidating CSS imports, and implementing a progressive reveal pattern for toolbar elements to prevent layout issues during PDF loading in WASM environments.
- Removed deprecated
::deepCSS selectors and replaced with standard selectors - Added progressive reveal pattern using
invisibleclass for toolbar elements - Consolidated CSS loading by importing
pdf_viewer.cssintopdf_reader.css
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pdf_reader.css | Added @import for pdf_viewer.css and removed deprecated ::deep selectors for thumbnail items |
| PdfReader.razor.js | Changed CSS file reference from pdf_viewer.css to pdf_reader.css and added logic to remove invisible class after initialization |
| PdfReader.razor | Added invisible class to toolbar and info elements to hide them until PDF is loaded |
| BootstrapBlazor.PdfReader.csproj | Bumped version from 10.0.9 to 10.0.10 |
Comments suppressed due to low confidence (10)
src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js:121
- Unused variable title.
const title = el.querySelector('.bb-view-pdf-dialog-title');
src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js:122
- Unused variable author.
const author = el.querySelector('.bb-view-pdf-dialog-author');
src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js:123
- Unused variable subject.
const subject = el.querySelector('.bb-view-pdf-dialog-subject');
src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js:124
- Unused variable keywords.
const keywords = el.querySelector('.bb-view-pdf-dialog-keywords');
src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js:128
- Unused variable modified.
const modified = el.querySelector('.bb-view-pdf-dialog-modified');
src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js:148
- Unused variable webview.
const webview = el.querySelector('.bb-view-pdf-dialog-webview');
src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js:469
- Unused variable scaleEl.
const scaleEl = el.querySelector(".bb-view-scale-input");
src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js:570
- The initial value of v is unused, since it is always overwritten.
let v = 100;
src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js:431
- Avoid automated semicolon insertion (94% of all statements in the enclosing function have an explicit semicolon).
})
src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js:493
- Avoid automated semicolon insertion (91% of all statements in the enclosing function have an explicit semicolon).
delete el.widths
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Link issues
fixes #769
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add support for a new PdfReader stylesheet and defer displaying the toolbar and controls until the viewer is initialized.
New Features:
Enhancements: