-
Notifications
You must be signed in to change notification settings - Fork 117
Fix Masonry Script Issues in BuddyX Theme #2227
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
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.
Pull request overview
This PR fixes critical JavaScript issues preventing the Masonry cascading grid layout from initializing properly in rtMedia galleries within the BuddyX theme. The changes address two root causes: a type mismatch between boolean and string values, and incompatibility with Masonry v4.x API.
Key Changes:
- Updated all masonry layout condition checks to handle both boolean
trueand string"true"values - Enhanced
rtm_masonry_reload()function to detect available Masonry API methods and use appropriate fallback for v4.x compatibility - Applied consistent strict equality comparisons throughout the codebase
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| app/assets/js/rtMedia.js | Updated masonry layout checks in 5 locations to handle both boolean and string types; refactored rtm_masonry_reload() to support both jQuery bridge and native Masonry v4.x API |
| app/assets/js/rtmedia.min.js | Minified version reflecting all source changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/assets/js/rtMedia.js
Outdated
| "activity_get_older_updates" === get_action) && | ||
| "undefined" !== typeof rtmedia_masonry_layout && | ||
| "true" === rtmedia_masonry_layout && | ||
| ("true" === rtmedia_masonry_layout || true === rtmedia_masonry_layout) && |
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.
Can we make a common function that will check both the string "true" and the boolean true value? and use it at all places
|
Unable to PHPCS or SVG scan one or more files due to error running PHPCS/SVG scanner:
The error may be temporary. If the error persists, please contact a human (commit-ID: 443f686). |
Description
This PR fixes issues with the Masonry cascading grid layout not initializing properly on media gallery pages in BuddyX Theme.
Solves #2223
Problem
When Masonry layout is enabled in rtMedia Settings:
$(...).masonry("reload") is not a valid methoderrorsRoot Causes
Boolean/String Type Mismatch: The
rtmedia_masonry_layoutvariable comparison was checking for string"true"but the value could be booleantrue. In JavaScript,true == "true"returnsfalse.Masonry v4.x API: The
reload()method doesn't exist in Masonry v4.x core - it's only added by the jQuery bridge. When the bridge isn't available, the call fails.Solution
rtm_masonry_reload()to check method availability and use native Masonry v4.x methods as fallbackTesting Instructions
Setup
npx grunt build(ornpx grunt terserfor JS only)Test Masonry
masonry("reload")