Skip to content

Render fulfillment container only when applicable#402

Merged
JPrevost merged 7 commits into
mainfrom
use-611
Jun 9, 2026
Merged

Render fulfillment container only when applicable#402
JPrevost merged 7 commits into
mainfrom
use-611

Conversation

@jazairi

@jazairi jazairi commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

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
  • ANDI or WAVE has been run in accordance to our guide.
  • This PR contains no changes to the view layer.
  • New issues flagged by ANDI or WAVE have been resolved.
  • New issues flagged by ANDI or WAVE have been ticketed (link in the Pull Request details above).
  • No new accessibility issues have been flagged.
New ENV
  • All new ENV is documented in README.
  • All new ENV has been added to Heroku Pipeline, Staging and Prod.
  • ENV has not changed.
Approval beyond code review
  • UXWS/stakeholder approval has been confirmed.
  • UXWS/stakeholder review will be completed retroactively.
  • UXWS/stakeholder review is not needed.
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
  • I have confirmed that the code works as intended.
  • Any CodeClimate issues have been fixed or confirmed as
    added technical debt.
Documentation
  • The commit message is clear and follows our guidelines
    (not just this pull request message).
  • The documentation has been updated or is unnecessary.
  • New dependencies are appropriate or there were no changes.
Testing
  • There are appropriate tests covering any new functionality.
  • No additional test coverage is required.

@qltysh

qltysh Bot commented Jun 4, 2026

Copy link
Copy Markdown

❌ 1 blocking issue (2 total)

Tool Category Rule Count
rubocop Style Line is too long. [123/120] 1
qlty Structure Function with high complexity (count = 9): load 1

@coveralls

coveralls commented Jun 4, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 27033899446

Coverage at 98.333% (no base build to compare)

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 12 of 12 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1440
Covered Lines: 1416
Line Coverage: 98.33%
Coverage Strength: 74.58 hits per line

💛 - Coveralls

@mitlib mitlib temporarily deployed to timdex-ui-pi-use-611-oftuzrder June 4, 2026 16:29 Inactive

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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-link elements when a .libkey-link is present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/javascript/controllers/content_loader_controller.js Outdated
@jazairi jazairi temporarily deployed to timdex-ui-pi-use-611-oftuzrder June 4, 2026 16:34 Inactive
@jazairi jazairi requested a review from Copilot June 4, 2026 16:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@jazairi jazairi temporarily deployed to timdex-ui-pi-use-611-oftuzrder June 4, 2026 17:40 Inactive
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.
Comment thread app/javascript/controllers/content_loader_controller.js Fixed
// Remove result-get container (no fulfillment links)
parentElement.remove();
}
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function with high complexity (count = 7): load [qlty:function-complexity]

@jazairi jazairi temporarily deployed to timdex-ui-pi-use-611-oftuzrder June 4, 2026 17:41 Inactive
@jazairi jazairi temporarily deployed to timdex-ui-pi-use-611-oftuzrder June 4, 2026 17:50 Inactive
@jazairi jazairi requested a review from Copilot June 4, 2026 19:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread app/javascript/controllers/content_loader_controller.js
Comment thread app/javascript/controllers/content_loader_controller.js Outdated
@jazairi jazairi temporarily deployed to timdex-ui-pi-use-611-oftuzrder June 4, 2026 19:51 Inactive
@jazairi jazairi requested a review from Copilot June 4, 2026 19:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread app/javascript/controllers/content_loader_controller.js
Comment on lines +10 to +20
stripHtmlComments(input) {
let previous
let output = input

do {
previous = output
output = output.replace(/<!--[\s\S]*?-->/g, '')
} while (output !== previous)

return output
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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. 🙃

@jazairi jazairi temporarily deployed to timdex-ui-pi-use-611-oftuzrder June 5, 2026 00:02 Inactive

@djanelle-mit djanelle-mit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Final edit: I still see the result-get divs on the PR build. There was a couple cases where they were gone but I can't reproduce them now.

@JPrevost JPrevost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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, '')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are there actually HTML comments we need to strip? I see whitespace, but that's handled by the trim without this new method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The deeper I go into this, the more confused I get. Yesterday I was seeing comments. Now I'm just seeing whitespace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see. This config setting is the culprit. I was looking at the changes in my local, so I was solving for a problem that doesn't actually exist in prod environments.

The good news is, trimming whitespace makes this much simpler.

@jazairi jazairi temporarily deployed to timdex-ui-pi-use-611-oftuzrder June 5, 2026 16:05 Inactive
@jazairi jazairi temporarily deployed to timdex-ui-pi-use-611-oftuzrder June 5, 2026 16:05 Inactive
@jazairi jazairi requested review from JPrevost and djanelle-mit June 5, 2026 16:20
@jazairi jazairi temporarily deployed to timdex-ui-pi-use-611-oftuzrder June 5, 2026 17:33 Inactive
Comment thread app/helpers/results_helper.rb Outdated
@jazairi jazairi temporarily deployed to timdex-ui-pi-use-611-oftuzrder June 5, 2026 18:47 Inactive
Comment thread app/helpers/results_helper.rb Outdated
Comment thread app/helpers/results_helper.rb Outdated
end
end

test 'result_get? returns true when result has both full record and PDF links even if record_link feature is disabled' do

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line is too long. [123/120] [rubocop:Layout/LineLength]

Comment thread test/helpers/results_helper_test.rb Outdated
Comment thread test/helpers/results_helper_test.rb Outdated
@jazairi jazairi temporarily deployed to timdex-ui-pi-use-611-oftuzrder June 5, 2026 18:51 Inactive
@JPrevost JPrevost self-assigned this Jun 8, 2026
@JPrevost

JPrevost commented Jun 9, 2026

Copy link
Copy Markdown
Member

I'm going to merge to unblock @djanelle-mit

@JPrevost JPrevost merged commit cfc3554 into main Jun 9, 2026
6 checks passed
@JPrevost JPrevost deleted the use-611 branch June 9, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants