Skip to content

Commit 0d76c69

Browse files
Fix featured filters by removing Alpine v2 conflict.
Alpine v2 was overwriting Livewire 3's Alpine and blocking DOM updates, so month/language changes never refreshed the list. Default to all months and paginate 24-per-page so the full open-online set is browsable. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b23e213 commit 0d76c69

3 files changed

Lines changed: 29 additions & 30 deletions

File tree

‎app/Livewire/OnlineCalendar.php‎

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ class OnlineCalendar extends Component
1818

1919
public $selectedMonth;
2020

21-
public $selectedDate;
21+
public $selectedDate = 'all';
2222

2323
public $months = [];
2424

2525
public function mount()
2626
{
2727
$this->selectedYear = Carbon::now()->year;
2828
$this->selectedMonth = Carbon::now()->month;
29-
$this->selectedDate = $this->selectedMonth.'/'.$this->selectedYear;
30-
// Default to all languages so the list is not silently reduced/restored by locale.
29+
$this->selectedDate = 'all';
3130
$this->selectedLanguage = '';
3231

3332
$this->months = $this->baseQuery()
@@ -48,13 +47,6 @@ public function mount()
4847
})
4948
->values()
5049
->toArray();
51-
52-
if (! empty($this->months)) {
53-
$parts = explode('/', $this->months[0]['id']);
54-
$this->selectedMonth = (int) $parts[0];
55-
$this->selectedYear = (int) ($parts[1] ?? $this->selectedYear);
56-
$this->selectedDate = $this->selectedMonth.'/'.$this->selectedYear;
57-
}
5850
}
5951

6052
public function updatedSelectedDate(): void
@@ -69,15 +61,18 @@ public function updatedSelectedLanguage(): void
6961

7062
public function render()
7163
{
72-
$parts = explode('/', (string) $this->selectedDate);
73-
$this->selectedMonth = (int) ($parts[0] ?: $this->selectedMonth);
74-
$this->selectedYear = (int) ($parts[1] ?? $this->selectedYear);
64+
$query = $this->baseQuery()->orderBy('start_date');
7565

76-
$events = $this->baseQuery()
77-
->whereMonth('start_date', $this->selectedMonth)
78-
->whereYear('start_date', $this->selectedYear)
79-
->orderBy('start_date')
80-
->get();
66+
if ($this->selectedDate && $this->selectedDate !== 'all') {
67+
$parts = explode('/', (string) $this->selectedDate);
68+
$this->selectedMonth = (int) ($parts[0] ?: $this->selectedMonth);
69+
$this->selectedYear = (int) ($parts[1] ?? $this->selectedYear);
70+
71+
$query->whereMonth('start_date', $this->selectedMonth)
72+
->whereYear('start_date', $this->selectedYear);
73+
}
74+
75+
$events = $query->get();
8176

8277
$events->each(function ($event) {
8378
$event->title = str_limit($event->title, 50);
@@ -113,13 +108,17 @@ public function render()
113108
->toArray();
114109

115110
$totalUpcoming = $this->baseQuery()->count();
111+
$monthLabel = $this->selectedDate === 'all' || ! $this->selectedDate
112+
? 'all upcoming months'
113+
: Carbon::createFromDate($this->selectedYear, $this->selectedMonth, 1)->format('F Y');
116114

117115
return view('livewire.online-calendar', [
118116
'countryNames' => $this->getCountryNamesFromEvents($events),
119117
'languages' => $languages,
120-
'filteredEvents' => $filteredEvents->paginate(50),
118+
'filteredEvents' => $filteredEvents->paginate(24),
121119
'totalUpcoming' => $totalUpcoming,
122120
'visibleCount' => $filteredEvents->count(),
121+
'monthLabel' => $monthLabel,
123122
]);
124123
}
125124

‎resources/views/livewire/online-calendar.blade.php‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
wire:model.live="selectedDate"
1414
class="w-full appearance-none rounded-full border border-slate-200 bg-white py-3 pl-12 pr-10 text-slate-500 font-semibold focus:outline-none focus:ring-2 focus:ring-[#1C4DA1]"
1515
>
16-
@forelse($months as $month)
16+
<option value="all">All months</option>
17+
@foreach($months as $month)
1718
<option value="{{ $month['id'] }}">{{ $month['name'] }}</option>
18-
@empty
19-
<option value="{{ $selectedDate }}">Select month</option>
20-
@endforelse
19+
@endforeach
2120
</select>
2221
</div>
2322
</div>
@@ -44,20 +43,20 @@ class="w-full appearance-none rounded-full border border-slate-200 bg-white py-3
4443
<div class="absolute top-0 w-full h-64 bg-yellow-50 hidden lg:block xl:hidden" style="clip-path: ellipse(70% 90% at 50% 90%)" ></div>
4544
<div class="absolute top-0 w-full h-64 bg-yellow-50 hidden xl:block" style="clip-path: ellipse(65% 90% at 50% 90%)" ></div>
4645
<div class="bg-yellow-50">
47-
<div class="codeweek-container-lg relative pt-10 pb-16 md:pb-28">
46+
<div class="codeweek-container-lg relative pt-10 pb-16 md:pb-28" wire:key="calendar-{{ $selectedDate }}-{{ $selectedLanguage }}-{{ $filteredEvents->currentPage() }}">
4847
<p class="text-center text-slate-500 text-lg mb-8">
4948
Showing {{ $visibleCount }} of {{ $totalUpcoming }} upcoming open online activities
50-
@if($selectedDate)
51-
for {{ \Carbon\Carbon::createFromDate($selectedYear, $selectedMonth, 1)->format('F Y') }}
52-
@endif
49+
for {{ $monthLabel }}
5350
</p>
5451
@if(count($filteredEvents) > 0)
5552
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 xl:gap-10">
5653
@foreach($filteredEvents as $event)
57-
@include('online-calendar._oc-event-simple')
54+
<div wire:key="event-{{ $event->id }}">
55+
@include('online-calendar._oc-event-simple')
56+
</div>
5857
@endforeach
5958
</div>
60-
<div>
59+
<div class="mt-10">
6160
{{ $filteredEvents->links('vendor.pagination') }}
6261
</div>
6362
@else

‎resources/views/online-calendar/oc-index.blade.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
@include('components.tailwind')
1717
@include('components.livewire')
1818

19-
@include('components.alpine')
19+
{{-- Do not include Alpine v2 here. Livewire 3 already ships Alpine v3;
20+
loading Alpine v2 breaks Livewire DOM updates (filters appear to do nothing). --}}
2021

2122
@section('content')
2223
<section id="codeweek-digital-girls" class="font-['Blinker'] overflow-hidden">

0 commit comments

Comments
 (0)