How to retain the highlight on the right-clicked time slot

I am having a design issue on the calendar with context menu. 

So when the user right clicks on the timeslot, the context menu opens. The user then selects from the context menu that will open a modal. The split second between opening the modal and selecting from the context menu, hovers the mouse pointer to a different timeslot and then it gets highlighted.

The requirement is, whichever time is right clicked, that slot should remain highlighted when the modal opens


The image below with the green arrow indicates that a user may click on that portion of New Appointment menu in line with 9:20AM slot although the user targets to create an appointment at 9:00AM





3 Replies

NR Nevitha Ravi Syncfusion Team November 17, 2021 11:13 AM UTC

Hi Bob, 

Greetings from Syncfusion Support. 

We have checked your reported issue ‘retain highlight on right clicked cell’ at our end and let you know that the highlight of the right-clicked cell remains properly. Please refer to the following sample for your reference. 

Also, we suspect that you have added some customization in your application which may result such issue so please share following details to validate the issue further at our end. 
  • Whether you have added any class to right-clicked cell?
  • Share scheduler and context menu related code snippets
  • Share issue replicating sample or try to replicate the issue in above sample.

Regards, 
Nevitha 



BJ BOB JASON TIAMSIC November 17, 2021 01:14 PM UTC

Yes, I have OnHover event implemented


public onHover(event: HoverEventArgs): void {
        this.tooltipObj.close();
        this.menuObj.close();

        if (!event.element || !event.event.target) {
            return;
        }

        const hoverTarget: HTMLElement = closest((event.event.target as Element), '.e-appointment') as HTMLElement;
        if (hoverTarget) {
            this.closeNewAppointmentTooltip();

            // We are hovering over an appointment
            this.resetNewAppointmentBlock();
            this.patientAppointment = this.scheduleObj.getEventDetails(hoverTarget) as ATIAppointment;
            if (this.patientAppointment.apptStatus != 3) {
                let location = this.locations.find(c => c.deptNum === this.patientAppointment.deptNum);
                if (location) {
                    this.patientAppointment.location = location.locationName;
                }
            }
            if (this.patientAppointment.apptStatus == 2) {
                this.fetchCancelationReason();
            }
            this.setAttributes();
            this.tooltipObj.open(event.element);
            this.tooltipObj.open(hoverTarget);
        }
        else {

            const hoverEmptyTarget: HTMLElement = closest((event.event.target as Element), '.e-work-cells') as HTMLElement;
            if (hoverEmptyTarget) {
                const newApptBlockId = 'newApptBlockId';
                const newApptEllipseId = 'newApptEllipseId';

                const existingNewApptBlock = document.getElementById(newApptBlockId);
                if (existingNewApptBlock && hoverEmptyTarget.id !== newApptBlockId) {
                    existingNewApptBlock.outerHTML = this.emptyCellOuterHtml;
                    existingNewApptBlock.innerText = this.emptyCellInnerText;
                    this.closeNewAppointmentTooltip();
                }

                let height: string = hoverEmptyTarget.style.height;

                if (hoverEmptyTarget.id !== newApptBlockId) {
                    this.emptyCellOuterHtml = hoverEmptyTarget.outerHTML;
                    this.emptyCellInnerText = hoverEmptyTarget.innerText;
                    hoverEmptyTarget.id = newApptBlockId;
                    hoverEmptyTarget.innerText = "";

                    const ele: any = this.scheduleObj.getCellDetails(hoverEmptyTarget);

                    let hasAppointments: Boolean = false;
                    if (!this.scheduleObj.isSlotAvailable(ele.startTime, ele.endTime, ele.groupIndex)) {
                        hasAppointments = true;
                    }

                    const elipse: string = '<div class="elipse-block-d" id="' + newApptEllipseId + '"><i class="fa fa-ellipsis-v elipse" id="elipseMenu"></i></div>';
                    const label: string = 'New Appointment ' + this.getTimeStringForEmptyCell(ele.startTime);
                    let newApptBlock: string = '<div class="template-wrap empty-cell-new-appt"><div class="new-appt-label-d"> <i class="fa fa-plus-circle plus-circle"></i>' + label + '</div>' + elipse + '</div>';
                    const htmlToUpdate = hoverEmptyTarget.outerHTML;

                    hoverEmptyTarget.outerHTML = htmlToUpdate.replace('</td>', newApptBlock + '</td>');
                    hoverEmptyTarget.style.maxHeight = height;
                    hoverEmptyTarget.style.height = height;

                    if (hasAppointments) {
                        document.getElementById(newApptEllipseId).addEventListener('mouseover', (event: MouseEvent) => {
                            this.createNewAppointmentTooltip(newApptEllipseId, this.getTimeStringForEmptyCell(ele.startTime));
                        });
                    }

                    document.getElementById(newApptEllipseId).addEventListener('click', (event: MouseEvent) => {
                        this.showContextMenuFromNewAppointmentBlock(event);
                    });

                    document.getElementById(newApptBlockId).addEventListener('dblclick', (event: MouseEvent) => {
                        this.showNewAppointment(event);
                    });
                }
            } else {
                this.resetNewAppointmentBlock();
            }

            event.event.stopPropagation();
        }
    }


VD Vinitha Devi Murugan Syncfusion Team November 18, 2021 12:30 PM UTC

Hi Bob, 
 
Thanks for your update. 
 
We have validated your reported issue at our end by modified our previously shared sample with your shared hover event. But unfortunately, we were unable to replicate the issue at our end. Please refer the working sample from the following link. 
 
 
Kindly check the above sample, If you still face the problem at your end, please share below details to validate the issue. 
 
  • Syncfusion package version
  • Share issue video demo with procedure.
  • Try to replicate the issue in above sample or share issue reproducing sample.
 
Regards, 
Vinitha 


Loader.
Up arrow icon