Using a relationships entry title as a repeatable components entry title

Hi!

I just thought I would share an extension I’ve working on. In my project, we link many content entries together using relationships inside components. However, it’s currently not possible to make the title of a repeatable component to be the entry title of a relationship established inside of the component. Ex:

In this example, I would want the title of the Button relationship to show in the expandable repeatable component.

I was able to do this by extending this file: extensions/content-manager/admin/src/components/RepeatableComponent/DraggedItem/utils/select.js

import { useMemo } from 'react';
import { get, toString } from 'lodash';
import { useContentManagerEditViewDataManager } from 'strapi-helper-plugin';

function useSelect({ schema, componentFieldName }) {
  const {
    checkFormErrors,
    modifiedData,
    moveComponentField,
    removeRepeatableField,
    triggerFormValidation,
  } = useContentManagerEditViewDataManager();

  const mainField = useMemo(() => get(schema, ['settings', 'mainField'], 'id'), [schema]);
  const nestedObjectTitle = schema.layouts.edit?.[0]?.[0]?.metadatas?.mainField?.name;
  const nestedObjectField = schema.layouts.edit?.[0]?.[0]?.name;
  const displayValuePath = (mainField === 'id' && !!nestedObjectTitle)
    ? [...componentFieldName.split('.'), nestedObjectField, nestedObjectTitle]
    : [...componentFieldName.split('.'), mainField];
  const displayedValue = toString(
    get(modifiedData, displayValuePath, '')
  );

  return {
    displayedValue,
    mainField,
    checkFormErrors,
    moveComponentField,
    removeRepeatableField,
    schema,
    triggerFormValidation,
  };
}

export default useSelect;

With this extension, the repeatable component will attempt to use the first items relationship entry title if a title for the repeatable component has not be specified.
Here is the result:

Just wanted to share in case someone was trying to solve the same problem!

Hey, I created this file exactly where you mentioned but it didn’t work. It’s still giving me only one option “id”. So, I thought maybe it isn’t extending for some reason so I went to the node_modules and edited this file there. It still didn’t work =(

Any hints?