-
-
Notifications
You must be signed in to change notification settings - Fork 254
v4.1.2 + upgrade
#1775
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
v4.1.2 + upgrade
#1775
Conversation
📝 WalkthroughWalkthroughAdded filamentSchema.isStateChanged; Mousetrap bindings now unbind on Livewire navigation; select components gain async update version-guard and fragment rendering; tables column select uses versioning to avoid stale renders; tables initializer signature changed to add selectsGroupsOnly and renamed parameters. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant App as filament/app (Mousetrap)
participant MT as Mousetrap
participant LW as Livewire
User->>App: initialize mousetrap directive
App->>MT: bind keys (i)
note right of App: Register listener for navigation cleanup
LW->>App: livewire:navigating event
rect rgba(220,200,255,0.18)
App->>MT: unbind keys (i) %% new cleanup path
end
sequenceDiagram
autonumber
participant Component as SelectComponent
participant API as async label fetch
participant DOM as Document
Component->>Component: increment selectedDisplayVersion (v)
Component->>API: fetch labels (async)
API-->>Component: labels (async response)
alt response version matches v
Component->>DOM: render into DocumentFragment
Component->>DOM: replace target node with fragment
else response stale
Component-->>DOM: discard update (no DOM change)
end
Pre-merge checks❌ Failed checks (2 warnings, 1 inconclusive)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 2
🧹 Nitpick comments (5)
public/js/filament/filament/app.js (1)
1-1: Unbind global Mousetrap combos too to avoid stale “global” flags after navigationThe navigating handler correctly unbinds current combos, but the Mousetrap plugin’s global map isn’t cleared, so future re-binds of the same combo will remain global unintentionally.
Add an unbindGlobal helper to the plugin and call it alongside unbind:
(function(t){if(t){ var n={}, i=t.prototype.stopCallback; t.prototype.stopCallback=function(l,g,c,_){ var y=this; return y.paused?!0:n[c]||n[_]?!1:i.call(y,l,g,c) }, t.prototype.bindGlobal=function(l,g,c){ var _=this; if(_.bind(l,g,c), l instanceof Array){ for(var y=0;y<l.length;y++) n[l[y]]=!0; return } n[l]=!0 }, + t.prototype.unbindGlobal=function(l){ + if (l instanceof Array) { for (var y=0; y<l.length; y++) delete n[l[y]]; return } + delete n[l] + }, t.init() }})(typeof Mousetrap<"u"?Mousetrap:void 0);Then, in the directive’s navigating handler:
- document.addEventListener("livewire:navigating",()=>{q.default.unbind(i)},{once:!0}) + document.addEventListener("livewire:navigating",()=>{ q.default.unbind(i); q.default.unbindGlobal?.(i) },{once:!0})public/js/filament/schemas/schemas.js (1)
1-1: Add cheap reference-equality fast path to isStateChangedAvoid stringify when values are already strictly equal.
- isStateChanged(e,n){if(e===void 0)return!1;try{return JSON.stringify(e)!==JSON.stringify(n)}catch{return e!==n}} + isStateChanged(e,n){ + if (e === void 0) return !1 + if (e === n) return !1 + try { return JSON.stringify(e) !== JSON.stringify(n) } + catch { return e !== n } + }public/js/filament/tables/components/columns/select.js (1)
1-1: Guard async search results against stale updatesRapid typing can render out‑of‑order results. Add a request/version counter similar to selectedDisplayVersion:
- this.searchTimeout=setTimeout(async()=>{ + const reqId = (this.searchRequestId = (this.searchRequestId ?? 0) + 1) + this.searchTimeout=setTimeout(async()=>{ this.searchTimeout=null this.isSearching=!0 try{ this.showLoadingState(!0) let i=await this.getSearchResultsUsing(e), n=Array.isArray(i)?i:i&&Array.isArray(i.options)?i.options:[] + if (reqId !== this.searchRequestId) return this.options=n this.populateLabelRepositoryFromOptions(n) this.hideLoadingState() this.renderOptions() this.isOpen&&this.positionDropdown() this.options.length===0&&this.showNoResultsMessage() }catch(i){ ... }finally{ this.isSearching=!1 } },this.searchDebounce)public/js/filament/tables/tables.js (2)
1-1: Align property naming: lastCheckedRecord vs lastCheckedState defines lastCheckedRecord but handlers use lastChecked. Use one consistently to avoid confusion and accidental shadowing:
- lastCheckedRecord:null, + lastChecked:null, ... - if(!this.lastChecked){ this.lastChecked=t; return } + if(!this.lastChecked){ this.lastChecked=t; return } ... - if(!o.includes(this.lastChecked)){ this.lastChecked=t; return } - let u=o.indexOf(this.lastChecked), m=o.indexOf(t) + if(!o.includes(this.lastChecked)){ this.lastChecked=t; return } + let u=o.indexOf(this.lastChecked), m=o.indexOf(t)Alternatively, rename usages to lastCheckedRecord.
1-1: New selectsGroupsOnly option is unusedThe initializer accepts selectsGroupsOnly (d) but it isn’t referenced. If intentional for future use, consider removing from the public signature for now; otherwise, wire it into group selection behavior.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
composer.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
public/js/filament/filament/app.js(1 hunks)public/js/filament/forms/components/select.js(1 hunks)public/js/filament/schemas/schemas.js(1 hunks)public/js/filament/tables/components/columns/select.js(1 hunks)public/js/filament/tables/tables.js(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- public/js/filament/forms/components/select.js
No description provided.