Skip to content

Commit

Permalink
Only use label_singular when one item is rendered in the listControl
Browse files Browse the repository at this point in the history
Fixes #1397.
Check the size of the item list and set the listlabel based on that.
If no label_singular is set, fall back to the normal label
  • Loading branch information
Robert Karlsson committed Jun 11, 2018
1 parent 78e4b82 commit aea97b2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/EditorWidgets/List/ListControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,15 @@ export default class ListControl extends Component {
const { value, forID, field, classNameWrapper } = this.props;
const { itemsCollapsed } = this.state;
const items = value || List();
const label = field.get('label_singular') || field.get('label');
const label = field.get('label');
const labelSingular = field.get('label_singular') || field.get('label');

return (
<div id={forID} className={c(classNameWrapper, 'nc-listControl')}>
<TopBar
allowAdd={field.get('allow_add', true)}
onAdd={this.handleAdd}
listLabel={label.toLowerCase()}
listLabel={items.size === 1 ? labelSingular.toLowerCase() : label.toLowerCase()}
onCollapseAllToggle={this.handleCollapseAllToggle}
allItemsCollapsed={itemsCollapsed.every(val => val === true)}
itemsCount={items.size}
Expand Down

0 comments on commit aea97b2

Please sign in to comment.