From 5a2effd2bc9e6bb30439aa683c484c5418da7f86 Mon Sep 17 00:00:00 2001 From: Josh <37798644+joshuaellis@users.noreply.github.com> Date: Mon, 14 Nov 2022 11:25:18 +0000 Subject: [PATCH] fix: design amends --- .../components/RelationInput/RelationInput.js | 22 ++++++++------- .../RelationInput/components/RelationItem.js | 27 +++++++++++-------- .../RelationInputDataManager.js | 1 + 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/packages/core/admin/admin/src/content-manager/components/RelationInput/RelationInput.js b/packages/core/admin/admin/src/content-manager/components/RelationInput/RelationInput.js index 6e7ae59e41..720cc1c8cd 100644 --- a/packages/core/admin/admin/src/content-manager/components/RelationInput/RelationInput.js +++ b/packages/core/admin/admin/src/content-manager/components/RelationInput/RelationInput.js @@ -81,6 +81,7 @@ const RelationInput = ({ publicationStateTranslations, required, relations: paginatedRelations, + toOneRelation, searchResults, size, }) => { @@ -261,6 +262,8 @@ const RelationInput = ({ } }, [previewRelationsLength, relations]); + const ariaDescriptionId = `${name}-item-instructions`; + return ( - {listAriaDescription} + {listAriaDescription} {liveText} relationsItems[index].id} @@ -395,16 +398,15 @@ RelationInput.defaultProps = { description: undefined, disabled: false, error: undefined, - iconButtonAriaLabel: 'Drag', labelAction: null, labelLoadMore: null, - listAriaDescription: 'Press spacebar to grab and re-order', liveText: undefined, onCancel: undefined, onDropItem: undefined, onGrabItem: undefined, required: false, relations: { data: [] }, + toOneRelation: false, searchResults: { data: [] }, }; @@ -412,13 +414,13 @@ RelationInput.propTypes = { error: PropTypes.string, description: PropTypes.string, disabled: PropTypes.bool, - iconButtonAriaLabel: PropTypes.string, + iconButtonAriaLabel: PropTypes.string.isRequired, id: PropTypes.string.isRequired, label: PropTypes.string.isRequired, labelAction: PropTypes.element, labelLoadMore: PropTypes.string, labelDisconnectRelation: PropTypes.string.isRequired, - listAriaDescription: PropTypes.string, + listAriaDescription: PropTypes.string.isRequired, liveText: PropTypes.string, loadingMessage: PropTypes.string.isRequired, name: PropTypes.string.isRequired, @@ -439,6 +441,7 @@ RelationInput.propTypes = { published: PropTypes.string.isRequired, }).isRequired, required: PropTypes.bool, + toOneRelation: PropTypes.bool, searchResults: SearchResults, size: PropTypes.number.isRequired, relations: RelationsResult, @@ -451,6 +454,7 @@ RelationInput.propTypes = { const ListItem = ({ data, index, style }) => { const { ariaDescribedBy, + canDrag, disabled, handleCancel, handleDropItem, @@ -460,12 +464,10 @@ const ListItem = ({ data, index, style }) => { onRelationDisconnect, publicationStateTranslations, relations, - totalNumberOfRelations, updatePositionOfRelation, } = data; const { publicationState, href, mainField, id } = relations[index]; const statusColor = publicationState === 'draft' ? 'secondary' : 'success'; - const canDrag = totalNumberOfRelations > 1; return ( props.theme.spaces[1]}; +`; + const RELATION_ITEM_DRAG_TYPE = 'RelationItem'; export const RelationItem = ({ @@ -189,17 +193,18 @@ export const RelationItem = ({ {...props} > {canDrag ? ( - - - + + + + + ) : null} {children} {endAction && {endAction}} diff --git a/packages/core/admin/admin/src/content-manager/components/RelationInputDataManager/RelationInputDataManager.js b/packages/core/admin/admin/src/content-manager/components/RelationInputDataManager/RelationInputDataManager.js index 46ea1f1af1..3485bd0120 100644 --- a/packages/core/admin/admin/src/content-manager/components/RelationInputDataManager/RelationInputDataManager.js +++ b/packages/core/admin/admin/src/content-manager/components/RelationInputDataManager/RelationInputDataManager.js @@ -346,6 +346,7 @@ export const RelationInputDataManager = ({ 'isSuccess' )} required={required} + toOneRelation={toOneRelation} searchResults={normalizeSearchResults(search, { mainFieldName: mainField.name, })}