wrong day highlighted when selecting a recurring event on week view

RESOLVED FIXED

Status

Calendar
General
RESOLVED FIXED
14 years ago
12 years ago

People

(Reporter: Andy Lanzone, Assigned: Mostafa Hosseini)

Tracking

Details

Attachments

(1 attachment)

(Reporter)

Description

14 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 Firebird/0.7
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031008 Thunderbird/0.3

In the week view, when I click on a recurring event, the wrong day is
highlighted.   For example, when I select a one-time event that happens on
Wednesday, the Wednesday column is highlighted (which is good).  But if I select
a _recurring_ event that happens on Wednesday, the Monday column is higlighted
(instead of Wednesday).  For some recurring events, no day is highlighted at all.

Reproducible: Always

Steps to Reproduce:
1. Create a recurring event
2. Switch to week view
3. Click on the recurring event to select it.  Usually, the wrong day (or no
day) is highlighted.



Expected Results:  
When any event (recurring or not) is selected, the day on which the event occurs
should be highlighted.
(Reporter)

Comment 1

14 years ago
Created attachment 136236 [details]
changes to calendar.js and weekView.js

I edited my calendar.js and weekView.js files to fix the problem.  In
calendar.js, I changed the function weekEventItemClick() to:

function weekEventItemClick( eventBox, event )
{
   //do this check, otherwise on double click you get into an infinite loop
   if( event.detail == 1 )
   {
      var cEvent = eventBox.calendarEventDisplay.event;
      gCalendarWindow.EventSelection.replaceSelection( cEvent );

      var startDate = gCalendarWindow.currentView.getFirstDate();

      if ( !cEvent.recur ) {
	 var newDate = gCalendarWindow.getSelectedDate();
	 newDate.setDate( cEvent.start.day );
	 gCalendarWindow.setSelectedDate( newDate );
      }
      else {
	 var isValid = false;
	 var result = new Object();
	 isValid = cEvent.getNextRecurrence( startDate.getTime(), result );

	 if ( isValid ) {
	     var newDate = new Date( result.value );
	     gCalendarWindow.setSelectedDate( newDate );
	 }
      }
      gCalendarWindow.EventSelection.replaceSelection( cEvent );
   }

   if ( event )
   {
      event.stopPropagation();
   }
} 

And in weekView.js, I added a new function getFirstDate():

WeekView.prototype.getFirstDate = function( )
{
   var FirstDate = new Date( gHeaderDateItemArray[1].getAttribute( "date" ) );

   return FirstDate;
}
(Assignee)

Comment 2

14 years ago
Interesting way of fixing the problem. But let's see if we can do this in an
easier way: 

eventBox.calendarEventDisplay.displayDate will give ( in milliseconds) the date
of the event which was clicked on. Can you instead make use of that value in
calculating the date that should be selected?
Summary: wrong day highlighted when selecting a recurring event on week view → wrong day highlighted when selecting a recurring event on week view
(Reporter)

Comment 3

14 years ago
You're right, there is a much easier way.  In calendar.js, change the function
weekEventItemClick() to:

function weekEventItemClick( eventBox, event )
{
   if( event.detail == 1 )
   {  
      var cEvent = eventBox.calendarEventDisplay.event;
      var newDate = new Date( eventBox.calendarEventDisplay.displayDate );
      gCalendarWindow.setSelectedDate( newDate );
      gCalendarWindow.EventSelection.replaceSelection( cEvent );
   }

   if ( event )
   {
      event.stopPropagation();
   }
}

No changes need to be made to weekView.js.  I think that is much cleaner.
(Assignee)

Comment 4

14 years ago
Thanks for the fix. Final change made to CVS:

diff -u -5 -r1.112 calendar.js
--- calendar.js	19 Nov 2003 17:21:56 -0000	1.112
+++ calendar.js	2 Dec 2003 21:08:14 -0000
@@ -386,13 +386,11 @@
    //do this check, otherwise on double click you get into an infinite loop
    if( event.detail == 1 )
    {
       gCalendarWindow.EventSelection.replaceSelection(
eventBox.calendarEventDisplay.event );
 
-      var newDate = gCalendarWindow.getSelectedDate();
-
-      newDate.setDate( eventBox.calendarEventDisplay.event.start.day );
+      var newDate = new Date( eventBox.calendarEventDisplay.displayDate );
 
       gCalendarWindow.setSelectedDate( newDate, false );
    }
 
    if ( event ) 
Status: UNCONFIRMED → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → FIXED
The bugspam monkeys have been set free and are feeding on Calendar :: General. Be afraid for your sanity!
QA Contact: gurganbl → general
You need to log in before you can comment on or make changes to this bug.