Skip to content

Commit

Permalink
🚸 [#454] Ensure role=group is only set if multiple buttons are displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Oct 19, 2023
1 parent e0ee350 commit f37a0d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/EditGrid/EditGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const EditGrid = ({children, onAddItem, addButtonLabel}) => (
<div>{children}</div>

{onAddItem && (
<ButtonGroup role="group">
<ButtonGroup>
<Button type="button" variant="primary" onClick={onAddItem}>
{addButtonLabel || <DefaultAddButtonLabel />}
</Button>
Expand Down
5 changes: 3 additions & 2 deletions src/components/EditGrid/EditGridButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import PropTypes from 'prop-types';
import React from 'react';

const EditGridButtonGroup = ({children}) => {
const role = children && React.Children.count(children) > 1 ? 'group' : undefined;
return (
<ButtonGroup role="group" className="utrecht-button-group--openforms-editgrid">
<ButtonGroup role={role} className="utrecht-button-group--openforms-editgrid">
{children}
</ButtonGroup>
);
};

EditGridButtonGroup.propTypes = {
children: PropTypes.node.isRequired,
children: PropTypes.arrayOf(PropTypes.node.isRequired),
};

export default EditGridButtonGroup;
5 changes: 4 additions & 1 deletion src/formio/templates/editGrid.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
<div>{{row}}</div>

{% if (ctx.openRows[rowIndex] && !ctx.readOnly) { %}
<p class="utrecht-button-group utrecht-button-group--openforms-editgrid" role="group">
<p
class="utrecht-button-group utrecht-button-group--openforms-editgrid"
{% if (ctx.component.removeRow) { %}role="group"{% } %}
>

<button
class="openforms-button openforms-button--primary utrecht-button utrecht-button--html-button utrecht-button--primary-action"
Expand Down

0 comments on commit f37a0d2

Please sign in to comment.