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: cannot toggle custom toolbar state(active, disabled) #1639

Merged
merged 6 commits into from
Jul 6, 2021

Conversation

js87zz
Copy link
Contributor

@js87zz js87zz commented Jul 6, 2021

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


Thank you for your contribution to TOAST UI product. 🎉 😘 ✨

@js87zz js87zz force-pushed the fix/toolbar-state branch from 868f133 to 30013ea Compare July 6, 2021 02:19
Copy link

@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.

리뷰 완료합니다.
사소한거지만 classname 이어붙이기 할 때 상태가 엮여들어가면 역시 코드가 지저분해지게 되는데 classnames 같은 방식으로 정의하는 것은 어떻게 보시나요? 캘린더에도 이런 형태의 헬퍼 함수를 하나 만들어서 적용하려 합니다.

@js87zz
Copy link
Contributor Author

js87zz commented Jul 6, 2021

@adhrinae

리뷰 완료합니다.
사소한거지만 classname 이어붙이기 할 때 상태가 엮여들어가면 역시 코드가 지저분해지게 되는데 classnames 같은 방식으로 정의하는 것은 어떻게 보시나요? 캘린더에도 이런 형태의 헬퍼 함수를 하나 만들어서 적용하려 합니다.

넵 좋네요ㅎㅎ 아래처럼 변경해서 조건에 따라 사용할게요~

export function cls(...names: (string | [boolean, string])[]) {
  const result = [];

  for (const name of names) {
    let className: string | null;

    if (Array.isArray(name)) {
      className = name[0] ? name[1] : null;
    } else {
      className = name;
    }

    if (className) {
      result.push(`${CLS_PREFIX}${className}`);
    }
  }

  return result.join(' ');
}

Copy link
Contributor

@jwlee1108 jwlee1108 left a comment

Choose a reason for hiding this comment

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

리뷰 완료합니다.

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.

리뷰완료합니다.

Comment on lines 49 to 53
if (item.onUpdated) {
if (prevProps.active !== active || prevProps.disabled !== disabled) {
item.onUpdated({ active, disabled });
}
}
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 (item.onUpdated) {
if (prevProps.active !== active || prevProps.disabled !== disabled) {
item.onUpdated({ active, disabled });
}
}
if (prevProps.active !== active || prevProps.disabled !== disabled) {
item.onUpdated?.({ active, disabled });
}

이렇게는 안될까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

좋네요ㅎㅎ

@js87zz js87zz merged commit 9dbfc65 into master Jul 6, 2021
@js87zz js87zz deleted the fix/toolbar-state branch July 6, 2021 06:55
ahamelers pushed a commit to ahamelers/tui.editor that referenced this pull request Aug 21, 2023
* fix: wron toolbarItems type definition

* refactor: lift up changing toolbar state logic to hoc

* chore: add test case(custom toolbar item active, disabled state)

* chore: change toolbar-item-wrapper css name

* chore: apply code review

* chore: apply code review - 2
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.

4 participants