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 31, 2023
1 parent 6c681e9 commit 519e65c
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>
<OFButton type="button" appearance="primary-action-button" onClick={onAddItem}>
{addButtonLabel || <DefaultAddButtonLabel />}
</OFButton>
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="utrecht-button utrecht-button--primary-action" ref="{{ctx.ref.saveRow}}">
{{ctx.t(ctx.component.saveRow || 'Save', { _userInput: true })}}
Expand Down

0 comments on commit 519e65c

Please sign in to comment.