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

[Bugfix] remove empty label when build value label in <SelectRow> #317

Merged
merged 1 commit into from
May 14, 2021

Conversation

chenesan
Copy link
Contributor

@chenesan chenesan commented May 13, 2021

Purpose

修掉 <SelectRow> 在找不到 value 對應的 label 時,仍會把空的值 join 起來做成 rowValueLabel 導致多了不需要的分隔符號的問題。
e.g. value = ['a','b'], labelMap = { a: 'a', }, separator = '/',則 SelectRow 的 valueLabel 應該要是 a,因為找不到 b 對應的 label。

現在會變成 a/,因為它在 labelMap 找不到對應的 value key 時仍然會把 undefined join 成 valueLabel。

Changes

  • a list of what have been done
  • maybe some code change

Risk

Usually none, if you have any please write it here.

TODOs

  • Describe what should be done outside of this PR
  • Maybe in other PRs or some manual actions.

@@ -200,6 +200,7 @@ class SelectRow extends PureComponent {
const valueMap = valueLabelMap.get(value) || {};
return valueMap.label;
})
.filter(label => Boolean(label))
Copy link
Member

Choose a reason for hiding this comment

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

也可以直接這樣,跟 @YuCJ 學到的 XD

Suggested change
.filter(label => Boolean(label))
.filter(Boolean)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

也是可以但稍微要想一下xd

@chenesan chenesan merged commit f2a10bd into develop May 14, 2021
@chenesan chenesan deleted the bugfix/remove_empty_label_in_select_row branch May 14, 2021 03:15
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.

5 participants