Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: solve side effects related to duplicate events #1226

Merged
merged 11 commits into from
Jul 27, 2022

Conversation

dotaitch
Copy link
Member

Please check if the PR fulfills these requirements

  • It's the right issue type on the title
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • It does not introduce a breaking change or has a description of the breaking change

Description

  • Fix an issue: the layout is broken when the collide event differs for each duplicate event.
Before After
bug-collideeventdiffers image
  • Fix an issue: going and coming durations are not showing in the collapsed event.
Before After
bug-durationsnotshowing image
  • Fix an issue: when there are too many events in one column, the width of the expanded event is less than the collapsed one.
Before After
bug-toomanyevents image
The width of the collapsed event was 5% of the column. Now, the width of the collapsed event is 9px.
  • Add an example for collapseDuplicateEvent option.
  • Update docs for collapseDuplicateEvent option.

Thank you for your contribution to TOAST UI product. ๐ŸŽ‰ ๐Ÿ˜˜ โœจ

@@ -107,6 +107,10 @@
/>
</button>
<span class="navbar--range"></span>
<div class="nav-checkbox">
<input class="checkbox-collapse" type="checkbox" id="collapse" value="collapse" />
<label for="collapse">Collapse duplicate events and disable the detail popup</label>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ค‘๋ณต ์ผ์ •์ด ๊ฒน์ณ์ง€๊ณ  ํŽผ์ณ์ง€๋Š” ๋™์ž‘์ด ์ž˜ ๋ณด์ด๋„๋ก collapseDuplicateEvents๋ฅผ ํ™œ์„ฑํ™”ํ•˜๋ฉด useDetailPopup๋ฅผ ๋„๋„๋ก ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.

@@ -266,11 +314,11 @@ export function setRenderInfoOfUIModels(

matrices.forEach((matrix) => {
const maxRowLength = Math.max(...matrix.map((row) => row.length));
const baseWidth = 100 / maxRowLength;
const baseWidth = Math.round(100 / maxRowLength);
Copy link
Member Author

@dotaitch dotaitch Jul 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ค‘๋ณต ์ผ์ •์˜ ๊ฒฝ์šฐ preact์— ์Šคํƒ€์ผ์„ ์ง€์ •ํ•  ๋•Œ left์™€ width๋ฅผ ๋ฌธ์ž์—ด๊ฐ’์œผ๋กœ ๋„˜๊ธฐ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ด ๋•Œ ๋‚˜๋ˆ„์–ด ๋–จ์–ด์ง€์ง€ ์•Š๋Š” baseWidth๋ฅผ ๊ฐ€์ง€๋Š” ๊ฒฝ์šฐ css ์Šคํƒ€์ผ์ด ์ œ๋Œ€๋กœ ์ ์šฉ๋˜์ง€ ๋ชปํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์ƒ๊ฒจ์„œ ๋ฐ˜์˜ฌ๋ฆผํ•˜๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

bug-basewidth

#### ๊ธฐ์กด์— ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์•˜๋˜ ์ด์œ 

๊ธฐ์กด์—๋Š” left์™€ width๋ฅผ number ํ˜•์‹์œผ๋กœ preact์— ๋„˜๊ธฐ๊ณ , preact ๋‚ด๋ถ€์—์„œ ์†Œ์ˆซ์ ์„ ์ฒ˜๋ฆฌํ•ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ํ˜„์žฌ ์ค‘๋ณต๋œ ์ผ์ •์˜ ๊ฒฝ์šฐ left์™€ width๋ฅผ string ํ˜•์‹์œผ๋กœ ๋„˜๊ธฐ๋„๋ก ๋ณ€๊ฒฝ๋˜๋ฉด์„œ preact์—์„œ ์ž๋™์œผ๋กœ ์ฒ˜๋ฆฌ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ทธ๋ƒฅ ๊ถ๊ธˆํ•ด์„œ์š”. preact ๋‚ด๋ถ€์—์„œ ์†Œ์ˆซ์  ์ฒ˜๋ฆฌํ•ด์คฌ๋‹ค๋Š” ๋ถ€๋ถ„์ด ์—ฌ๊ธด๊ฐ€์š”?

https://github.com/preactjs/preact/blob/17da4efa736f14c84cd9f36fca4420d94f0dd403/src/diff/props.js#L36-L46


์†Œ์ˆซ์ ์ด ๋„ˆ๋ฌด ๋งŽ์•„์ง€๋Š” ๋ถ€๋ถ„์€ ์˜ˆ์ „์—๋„ ๋ญ”๊ฐ€ ๋ฐ˜์˜ฌ๋ฆผ ์ฒ˜๋ฆฌ๋ฅผ ํ•˜๊ฑฐ๋‚˜ toFixed ๋ฅผ ์จ์•ผ ํ•˜์ง€ ์•Š์„๊นŒ ์ƒ๊ฐํ–ˆ๋‹ค๊ฐ€ ๊ดœ์ฐฎ์œผ๋‹ˆ๊นŒ ๋ƒ…๋’€๋Š”๋ฐ, ์ด๋Ÿฐ๋ถ€๋ถ„์—์„œ ์˜์™ธ์˜ ๋ฌธ์ œ๊ฐ€ ํ„ฐ์ง€๋Š”๊ตฐ์š” ๐Ÿค”

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„ ์ด ๋ถ€๋ถ„์€ ์ œ๊ฐ€ ์ž˜๋ชป ํŒŒ์•…ํ–ˆ๋„ค์š”. ๊ธฐ์กด์—๋„ number๊ฐ€ ์•„๋‹Œ string์œผ๋กœ ๋„˜๊ธฐ๊ณ  ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. (์ฐธ๊ณ  - TimeEvent.tsx L75-L79)

์ œ ์ƒ๊ฐ์—๋Š” ์ด๋ฒˆ์— ์ถ”๊ฐ€๋œ ํผ์„ผํŠธ ๊ฐ’์„ ๋”ํ•˜๊ณ  ๋นผ๋Š” ๊ณผ์ • ๋•Œ๋ฌธ์— ๋ถ€๋™์†Œ์ˆ˜์  ์˜ค๋ฅ˜๊ฐ€ ๋‚œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
๊ธฐ์กด์—๋Š” ๋ถ€๋™์†Œ์ˆ˜์ ์˜ ์—ฐ์‚ฐ์ด ์•„๋‹ˆ๋ผ 100 / baseWidth ์™€ ๊ฐ™์ด ๊ฒฐ๊ณผ๊ฐ€ ๋ถ€๋™์†Œ์ˆ˜์ ์œผ๋กœ ๋‚˜ํƒ€๋‚˜๋Š” ๊ฑฐ๋ผ ๋ฌธ์ œ๊ฐ€ ์—†์—ˆ๋Š”๋ฐ, ์ด๋ฒˆ์— ์ถ”๊ฐ€๋œ ๋กœ์ง์€ ๋ถ€๋™์†Œ์ˆ˜์ ๋ผ๋ฆฌ์˜ ์—ฐ์‚ฐ์ด๋ผ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•œ ๊ฒƒ ๊ฐ™์•„์š”.

Comment on lines +143 to +157
/**
* represent the left value of a duplicate event.
* ex) calc(50% - 24px), calc(50%), ...
*
* @type {string}
*/
duplicateLeft = '';

/**
* represent the width value of a duplicate event.
* ex) calc(50% - 24px), 9px, ...
*
* @type {string}
*/
duplicateWidth = '';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ธฐ์กด์˜ left์™€ width๋ฅผ ์ˆ˜์ •ํ•˜์ง€ ์•Š๊ณ  ์ƒˆ๋กœ์šด ํ”„๋กœํผํ‹ฐ๋ฅผ ๋งŒ๋“  ์ด์œ ๋Š” ํƒ€์ž… ๋ฌธ์ œ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. left์™€ width๊ฐ€ ๋ฌธ์ž์—ด๋„ ๊ฐ€๋Šฅํ•˜๋„๋ก number | string ํƒ€์ž…์œผ๋กœ ๋ฐ”๊พธ๋ฉด ๋‹ค๋ฅธ ๋งŽ์€ ๊ณณ์—์„œ ํƒ€์ž… ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜๊ณ , ์ด๋ฅผ ๋ชจ๋‘ ์ˆ˜์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ƒ๊ฐ๋ณด๋‹ค ์˜ํ–ฅ์„ ๋ผ์น˜๋Š” ๋ถ€๋ถ„์ด ๋งŽ์•„์„œ ์ƒˆ๋กœ์šด ํ”„๋กœํผํ‹ฐ๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.

Comment on lines +239 to +244
infos.push({
start: event.duplicateStarts as TZDate,
end: event.duplicateEnds as TZDate,
goingDuration: 0,
comingDuration: 0,
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicateStarts์—๋Š” ์ค‘๋ณต ์ผ์ • ๊ทธ๋ฃน ์ค‘ ๊ฐ€์žฅ ์ด๋ฅธ start + goingDuration์„, duplicateEnds์—๋Š” ๊ฐ€์žฅ ๋Šฆ์€ end + comingDuration์„ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. duplicateStarts๊ณผ duplicateEnds๋Š” ์ด๋ฏธ duration์„ ๊ณ ๋ คํ•œ ๊ฐ’์ด๊ธฐ ๋•Œ๋ฌธ์— ์ถฉ๋Œ์„ ๊ณ„์‚ฐํ•  ๋•Œ๋Š” goingDuration๊ณผ comingDuration์„ 0์œผ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

Copy link
Contributor

@adhrinae adhrinae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฆฌ๋ทฐ ์™„๋ฃŒํ•ฉ๋‹ˆ๋‹ค. ์–ด๋ ค์šด ๊ธฐ๋Šฅ ๊ตฌํ˜„ํ•˜๋Š๋ผ ๋ฌด์ฒ™ ๊ณ ์ƒํ•˜์…จ์–ด์š”.

์ž์ž˜ํ•˜๊ฒŒ ์ฝ”๋“œ ๋‹ค๋“ฌ์–ด์ฃผ์…จ์œผ๋ฉด ํ•˜๋Š” ๋ถ€๋ถ„, ์„ค๋ช…์ด ์กฐ๊ธˆ ๋” ํ•„์š”ํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋Š” ๋ถ€๋ถ„ ๋“ฑ ์ฝ”๋ฉ˜ํŠธ ๋‚จ๊ฒผ์Šต๋‹ˆ๋‹ค.

apps/calendar/src/factory/calendarCore.tsx Outdated Show resolved Hide resolved
@@ -266,11 +314,11 @@ export function setRenderInfoOfUIModels(

matrices.forEach((matrix) => {
const maxRowLength = Math.max(...matrix.map((row) => row.length));
const baseWidth = 100 / maxRowLength;
const baseWidth = Math.round(100 / maxRowLength);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ทธ๋ƒฅ ๊ถ๊ธˆํ•ด์„œ์š”. preact ๋‚ด๋ถ€์—์„œ ์†Œ์ˆซ์  ์ฒ˜๋ฆฌํ•ด์คฌ๋‹ค๋Š” ๋ถ€๋ถ„์ด ์—ฌ๊ธด๊ฐ€์š”?

https://github.com/preactjs/preact/blob/17da4efa736f14c84cd9f36fca4420d94f0dd403/src/diff/props.js#L36-L46


์†Œ์ˆซ์ ์ด ๋„ˆ๋ฌด ๋งŽ์•„์ง€๋Š” ๋ถ€๋ถ„์€ ์˜ˆ์ „์—๋„ ๋ญ”๊ฐ€ ๋ฐ˜์˜ฌ๋ฆผ ์ฒ˜๋ฆฌ๋ฅผ ํ•˜๊ฑฐ๋‚˜ toFixed ๋ฅผ ์จ์•ผ ํ•˜์ง€ ์•Š์„๊นŒ ์ƒ๊ฐํ–ˆ๋‹ค๊ฐ€ ๊ดœ์ฐฎ์œผ๋‹ˆ๊นŒ ๋ƒ…๋’€๋Š”๋ฐ, ์ด๋Ÿฐ๋ถ€๋ถ„์—์„œ ์˜์™ธ์˜ ๋ฌธ์ œ๊ฐ€ ํ„ฐ์ง€๋Š”๊ตฐ์š” ๐Ÿค”

apps/calendar/src/controller/column.ts Outdated Show resolved Hide resolved
apps/calendar/src/controller/column.ts Show resolved Hide resolved
apps/calendar/src/controller/column.ts Show resolved Hide resolved
apps/calendar/src/controller/column.ts Show resolved Hide resolved
apps/calendar/src/helpers/css.ts Show resolved Hide resolved
Copy link
Contributor

@lja1018 lja1018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฆฌ๋ทฐ ์™„๋ฃŒํ•ฉ๋‹ˆ๋‹ค.

apps/calendar/src/controller/column.spec.ts Outdated Show resolved Hide resolved
apps/calendar/src/controller/column.ts Outdated Show resolved Hide resolved
apps/calendar/src/controller/column.ts Show resolved Hide resolved
Comment on lines +201 to +214
if (!isDuplicateEvent && uiModel.duplicateEvents.length > 0) {
uiModel.duplicateEvents.forEach((event) => {
setRenderInfo({
uiModel: event,
columnIndex,
baseWidth,
startColumnTime,
endColumnTime,
isDuplicateEvent: true,
});
});

return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์–ผ๋ฆฌ๋ฆฌํ„ด๋ณด๋‹ค

Suggested change
if (!isDuplicateEvent && uiModel.duplicateEvents.length > 0) {
uiModel.duplicateEvents.forEach((event) => {
setRenderInfo({
uiModel: event,
columnIndex,
baseWidth,
startColumnTime,
endColumnTime,
isDuplicateEvent: true,
});
});
return;
}
if (isDuplicateEvent || uiModel.duplicateEvents.length === 0) {
// ์•„๋ž˜ ๋กœ์ง
} else {
uiModel.duplicateEvents.forEach((event) => {
setRenderInfo({
uiModel: event,
columnIndex,
baseWidth,
startColumnTime,
endColumnTime,
isDuplicateEvent: true,
});
});
}

๊ฐ™์€ ๋ฐฉ์‹์€ ์–ด๋– ์‹ ๊ฐ€์š”?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ €๋Š” ๊ฐœ์ธ์ ์œผ๋กœ ์–ผ๋ฆฌ ๋ฆฌํ„ด์„ ๋” ์„ ํ˜ธํ•ฉ๋‹ˆ๋‹ค..ใ…Žใ…Žใ…Ž ๊ตณ์ด else ๋ฌธ์„ ๋งŒ๋“ค์–ด์„œ ์ธ๋ดํ…Œ์ด์…˜ ํ•œ ๋‹จ๊ณ„๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ์‹ถ์ง€ ์•Š๊ธฐ๋„ ํ•˜๊ณ , ์•„๋ž˜ ๋กœ์ง์—์„œ๋„ returnํ•˜๋Š” ๋กœ์ง์ด ์—†์–ด์„œ ์–ด๋Š ๋กœ์ง์„ ํƒ€๋”๋ผ๋„ ๋ฆฌํ„ด ํƒ€์ž…์ด ๋™์ผํ•˜๊ฒŒ undefined์ด ๋˜๊ฑฐ๋“ ์š”.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ˜น์‹œ else ์“ฐ๋Š” ๊ฑธ ์„ ํ˜ธํ•˜๋Š” ์ด์œ ๊ฐ€ ์žˆ๋‚˜์š”??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ง€๊ธˆ ํ•จ์ˆ˜๋Š” ๊ดœ์ฐฎ์€๋ฐ ํ•จ์ˆ˜๊ฐ€ ๊ธธ์–ด์ง€๊ณ  ๋กœ์ง์ด ๋ณต์žกํ•  ๋•Œ ์ค‘๊ฐ„์— ์–ผ๋ฆฌ๋ฆฌํ„ด์œผ๋กœ ๋น ์ ธ๋‚˜๊ฐ€๋ฉด ๋กœ์ง ํŒŒ์•…์ด ์‰ฝ์ง€ ์•Š๋”๋ผ๊ตฌ์š”.

๊ฐœ์ธ์ ์ธ ์˜๊ฒฌ์ด๋ผ ๋ฐ˜์˜ ์•ˆํ•˜์…”๋„ ๊ดœ์ฐฎ์Šต๋‹ˆ๋‹ค!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ €๋„ ๊ธฐ๋ณธ์ ์œผ๋ก  ์–ผ๋ฆฌ๋ฆฌํ„ด ์ข‹์•„ํ•˜๋Š”๋ฐ ์•„๋ฌด๊ฒƒ๋„ ๋ฆฌํ„ด ์•ˆํ•˜๊ณ  return ๋งŒ ์žˆ๋Š” ์–ผ๋ฆฌ๋ฆฌํ„ด๋ณด๋‹จ ๊ฐ’์ด ๋ช…์‹œ์ ์ธ ์–ผ๋ฆฌ๋ฆฌํ„ด์ด์–ด์•ผ ๊ทธ๋Ÿด๋งŒํ•œ ๊ฐ€์น˜๊ฐ€ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋Š” ํŽธ์ด์—์š”.

์ด ํ•จ์ˆ˜๋Š” ์•ฝ๊ฐ„ ๋‹ค๋ฅธ๋ฐ, ์žฌ๊ท€ํ•จ์ˆ˜์ด๋ฏ€๋กœ ์กฐ๊ฑด ์ข…๋ฃŒ ๋ถ€๋ถ„์ด ๋จผ์ € ํ•จ์ˆ˜ ์ƒ๋‹จ์— ๋“œ๋Ÿฌ๋‚˜์žˆ๋Š”๊ฒŒ ์ข‹๋‹ค๊ณ  ์ƒ๊ฐํ•ด์„œ ์ง€๊ธˆ ์ƒํƒœ๋กœ๋„ ์ถฉ๋ถ„ํ•˜๋‹ค ๋ด…๋‹ˆ๋‹ค.

์ œ ์ฝ”๋ฉ˜ํŠธ์—๋„ ์ผ์ง€๋งŒ ์ด๋Ÿฐ ํ˜•ํƒœ์˜ ์žฌ๊ท€๊ฐ€ ์•„๋‹Œ ๋‹ค๋ฅธ ๋ฐฉ์‹์œผ๋กœ ํ’€์–ด๋‚˜๊ฐˆ ์ˆ˜ ์žˆ์œผ๋ฉด ์ข‹๊ฒ ์ง€๋งŒ ๋งˆ๋•…ํ•œ ๊ฐœ์„  ์•„์ด๋””์–ด๊ฐ€ ๋– ์˜ค๋ฅด์ง€ ์•Š์•„ ๋„˜์–ด๊ฐ€์‹œ์ฃ .

Base automatically changed from feat/duplicate-events to main July 27, 2022 04:44
@dotaitch dotaitch merged commit 74a9807 into main Jul 27, 2022
@dotaitch dotaitch deleted the fix/duplicate-event-layout branch July 27, 2022 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants