Conversation
1 new issue
|
Coverage Report for CI Build 26986953058Coverage remained the same at 98.319%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
This PR updates the Stimulus content-loader controller to avoid leaving empty fulfillment/link containers in the DOM when the fetched HTML response contains no meaningful content, reducing DOM pollution and preventing unintended spacing/layout artifacts in results.
Changes:
- If the fetched HTML is empty/whitespace-only, remove the loader element instead of replacing it with empty output.
- Preserve existing behavior that removes
.primo-linkelements when a.libkey-linkis present.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Why these changes are being introduced: The fulfillment link container currently renders as an empty div when no links are available. This pollutes the DOM and affects spacing. Relevant ticket(s): - [USE-611](https://mitlibraries.atlassian.net/browse/USE-611) How this addresses that need: This removes the parent div if no fulfillment links are present. Side effects of this change: Primo link removal moves further up in the control flow, because that check is not applicable if the parent element is gone.
| // Remove result-get container (no fulfillment links) | ||
| parentElement.remove(); | ||
| } | ||
| }) |
| stripHtmlComments(input) { | ||
| let previous | ||
| let output = input | ||
|
|
||
| do { | ||
| previous = output | ||
| output = output.replace(/<!--[\s\S]*?-->/g, '') | ||
| } while (output !== previous) | ||
|
|
||
| return output | ||
| } |
There was a problem hiding this comment.
The change Copilot is suggesting is what I originally had. It would override the existing code in this helper method, which was suggested in a prior Copilot review. 🙃
JPrevost
left a comment
There was a problem hiding this comment.
This doesn't seem to work. I still see the empty divs in Dave's example from the ticket. I suspect we are injecting them for records we never do lookups so this swap logic never comes into play. The issue may be we need to conditionally inject the divs to begin with (and still clean them up if they result in empty divs)?
It's quite early though so I'm marking this as comment and not request changes because I may not be understanding what is going on :)
|
|
||
| do { | ||
| previous = output | ||
| output = output.replace(/<!--[\s\S]*?-->/g, '') |
There was a problem hiding this comment.
Are there actually HTML comments we need to strip? I see whitespace, but that's handled by the trim without this new method.
Why these changes are being introduced:
The fulfillment link container currently renders
as an empty div when no links are available. This
pollutes the DOM and affects spacing.
Relevant ticket(s):
How this addresses that need:
Primo link removal moves further up in the control
flow, because that check is not applicable if the
parent element is gone.
Side effects of this change:
None.
Developer
Accessibility
New ENV
Approval beyond code review
Additional context needed to review
E.g., if the PR includes updated dependencies and/or data
migration, or how to confirm the feature is working.
Code Reviewer
Code
added technical debt.
Documentation
(not just this pull request message).
Testing