Skip to content

Commit 9fe5954

Browse files
committed
fix: not work afterRenderEvent ( fix #1327 )
1 parent 7fb2f20 commit 9fe5954

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

apps/calendar/src/components/events/horizontalEvent.spec.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,35 @@ describe('Color values', () => {
307307
});
308308

309309
describe('isReadOnly', () => {
310+
function setup() {
311+
const eventName = 'readonly-event';
312+
const uiModel = new EventUIModel(
313+
new EventModel({
314+
id: '1',
315+
title: eventName,
316+
start: new Date(2020, 0, 1, 10, 0),
317+
end: new Date(2020, 0, 1, 12, 0),
318+
isReadOnly: true,
319+
})
320+
);
321+
322+
const props = {
323+
uiModel,
324+
eventHeight: 30,
325+
headerHeight: 0,
326+
};
327+
328+
return {
329+
props,
330+
};
331+
}
332+
310333
it("should be able to show detail popup even if the model's `isReadOnly` property is `true`", () => {
311334
// Given
312335
const store = initCalendarStore({
313336
useDetailPopup: true,
314337
});
338+
315339
const eventName = 'readonly-event';
316340
const uiModel = new EventUIModel(
317341
new EventModel({
@@ -322,6 +346,7 @@ describe('isReadOnly', () => {
322346
isReadOnly: true,
323347
})
324348
);
349+
325350
const props = {
326351
uiModel,
327352
eventHeight: 30,
@@ -341,4 +366,18 @@ describe('isReadOnly', () => {
341366

342367
expect(showDetailPopupSpy).toHaveBeenCalled();
343368
});
369+
370+
it(`should fire 'afterRenderEvent' when it is in readonly mode`, () => {
371+
// Given
372+
const eventBus = new EventBusImpl<ExternalEventTypes>();
373+
const handler = jest.fn();
374+
eventBus.on('afterRenderEvent', handler);
375+
const { props } = setup();
376+
377+
// When (resizingWidth)
378+
render(<HorizontalEvent {...props} />, { eventBus });
379+
380+
// Then
381+
expect(handler).toBeCalled();
382+
});
344383
});

apps/calendar/src/components/events/horizontalEvent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export function HorizontalEvent({
170170
});
171171

172172
useEffect(() => {
173-
if (isDraggableEvent) {
173+
if (isNil(resizingWidth) && isNil(movingLeft)) {
174174
eventBus.fire('afterRenderEvent', uiModel.model.toEventObject());
175175
}
176176
// This effect is only for the first render.

0 commit comments

Comments
 (0)