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: truncated text when width is auto #1673
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 완료합니다~ 리뷰 남긴게 있는데 이건 이미 처리됐네요ㅎㅎ;; 참고차 리뷰는 안지우고 그대로 올릴게요!
const context = document.createElement('canvas').getContext('2d')!; | ||
context.font = font; | ||
const { width } = context.measureText(String(text)); | ||
export function getTextWidth(text: string, font?: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
font
인자값이 쓰이지 않네요. 추후 개발을 위해 font
를 나두어야 한다면 아래 eslint 룰을 적용해도 좋을 것 같아요. 참고로 TOAST UI Calendar에도 적용되어 있습니다.
https://eslint.org/docs/rules/no-unused-vars#argsignorepattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
늦게나마 리뷰 완료합니다. 디스패치에서 DOM 헬퍼를 직접 가져다 써야하는게 좀 아쉽긴한데 제대로 사이즈 재려면 어쩔수 없긴 하죠.
const bodyArea = document.querySelector( | ||
`.${cls('rside-area')} .${cls('body-container')} .${cls('table')}` | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bodyArea
를 인자로 받게 할 수는 없을까요? 인자를 넘기는게 코드가 좀 복잡해보이긴 하지만, 디스패치에서 이 함수를 루프에서 직접 호출하는게 너무 큰 사이드 이펙트라고 느껴져서요. 어차피 그리드가 마운트되고 나면 이 엘리먼트는 어디로 사라지는 것도 아니니까 reduce 루프의 상위 스코프에서 한 번만 찾고 인자로 전달하는 식으로 했음 좋겠네요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 완료합니다.
return texts.reduce((acc, text) => { | ||
return text.length > acc.length ? text : acc; | ||
}, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return texts.reduce((acc, text) => { | |
return text.length > acc.length ? text : acc; | |
}, ''); | |
return texts.reduce((acc, text) => text.length > acc.length ? text : acc, ''); |
바로 리턴할 수 있을 것 같아요.
Please check if the PR fulfills these requirements
fix #xxx[,#xxx]
, where "xxx" is the issue number)Description
As-Is
To-Be
Thank you for your contribution to TOAST UI product. 🎉 😘 ✨