وردپرس

View switching from the “List” to the “Day” possible js bug


Hi!
I have a problem with version 6.3.5 of the plugin when switching from the “List” view to the “Day” view.
The problem occurs when I scroll several pages forward on the “List” view, on the “Event Bar” or on the navigation at the footer of the “List” view.
Occurs only when the selected day on the Calendar control does not have enough events for the page the “List” is currently on.
For example day has only 5 events, the list shows 12 events by default, I switch the list to “Upcoming events” – I scroll for a few pages, for example to page 5.
If I then try to switch to the “Day” view, I get the message:

“No events scheduled for March 27, 2024. Jump to the next upcoming events.”

After that, I have to select a date on the “Calendar” control in the “Events Bar” and the events are displayed again.

The paged url parameter remained in the browser address:
https://test1.athelingsoft.com/?post_type=tribe_events&eventDisplay=day&paged=5

Through Debugging I found a dirty workaround in the file:
\wp-content\plugins\the-events-calendar\src\resources\js\views\manager.js
in a js function
obj.onLinkClick = function( event ) { … }

// Line 329
// change from
var url = $link.attr( 'href' );
// to
var url = ($link.attr("href")).indexOf("eventDisplay=day") > -1 ? ($link.attr("href")).replace(new RegExp('[?&]' + 'paged' + '=^&#?$'), '$1').replace(new RegExp('([?&])' + 'paged' + '=[^&]*&'), '$1') : $link.attr("href");

The regex pattern is borrowed from Stackoverflow, question 1634748, and tested on regex101.
This way I delete the “paged” URL parameter only when switching from the “List” to the “Day” view, when there is an “eventDisplay” URL parameter with the value “day” – “eventDisplay=day”.
Of course, I did the same in the manager.min.js file. The text is there:

url = $(this).attr("href"),
// changes with
url = ($(this).attr("href")).indexOf("eventDisplay=day") > -1 ? ($(this).attr("href")).replace(new RegExp('[?&]' + 'paged' + '=[^&#](#.)?$'), '$1 ').replace(new RegExp('([?&])' + 'paged' + '=[^&]*&'), '$1') : $(this).attr("href"),

I will mention that I did this the dirty way. After every plugin update, I have to repeat the replacement.

Of course, I have been able to perform basic troubleshooting steps from “Sticky”.
I set up a test site and activated theme Twenty Twenty-Two, the TEC plugin, FIFU and my plugin that I use for customizing.
When only TEC remains active, the same problem occurs, the behavior is the same, and it looks like a js bug to me.
When switching from the “List” to the “Day” view, the url parameter “page/paged” is sent in request, which creates a problem when changing the view.

Questions!
Does anyone have the same problem as I have?
Is there any better solution, or are there some improvements for my workaround?

Regards

The page I need help with: [log in to see the link]

این خبر را در ایران وب سازان مرجع وب و فناوری دنبال کنید

مشاهده پاسخ های این مطلب
———————————————
این مطلب از سایت انجمن وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد

منبع: انجمن وردپرس

دکمه بازگشت به بالا