Possibility to prevent the text to get highlighted when start editing an event with Scheduler.control.events.edit(event)

Asked by Anonymous
1 years ago.

I’m currently implementing inline edit in a react app, when props change from outside during an edit and the scheduler re-renders, I need to reenter the edit, which works just fine with Scheduler.control.events.edit(event), but the text is highlighted, is there an option to enter the edit mode without the text highlighted or would it posible to add this as an option when calling Scheduler.control.events.edit(event)?

Answer posted by Dan Letecky [DayPilot]
1 years ago.

You can cancel the selection and place the caret at the start using the onAfterEventEditRender event:

onAfterEventEditRender: args => {
  setTimeout(() => {
    args.element.setSelectionRange(0, 0);
  }, 0);
}

This event is called before the text is selected so you need to postpone the setSelectionRange() call using setTimeout().

Comment posted by Anonymous
1 years ago.

Thanks for the quick reply this works for me!

This question is more than 1 month old and has been closed. Please create a new question if you have anything to add.