Problem/Motivation

The current UX can lead to data loss on the edit form when the editor is not aware that pressing the "Generate references with AI" button will lose all changes on the edit form.

Current UX:

  • There is a "Generate references with AI" button on the node edit form.
  • When a user presses the "Generate references with AI" button, they are taken away from the node edit form.
  • On the AI Auto Reference form, the user can select reference suggestions to apply to the node.
  • When the user submits the AI Auto Reference form, the node is saved. This save overrides any changes that were made on the node edit form before pressing the "Generate references with AI" button.
  • The user is redirected back to the node edit which is built for the update node object.

Proposed resolution

  • Leverage the 'Field Widget Actions' module so per field suggestions can come up in modal window with choices
  • Provide control to site builder to choose one or both options (save and generate vs FWA)
  • Remaining tasks

  1. Implement proof of concept
  2. Contribute to FWA module to get checkboxes/radios into modal
  3. Contribute to FWA module to allow adding vs replacing (e.g. for cardinality > 0 fields)
  4. Ensure support for typical entity reference fields (probably only autocomplete, autocomplete (tags style), and tagify since the JS actually needs to see the target input fields on the screen for FWA)
  5. Update any documentation

User interface changes

Ability to enable field widget action via manage form display -> gear for entity reference/term reference fields.

API changes

None

Data model changes

None

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

recrit created an issue. See original summary.

recrit’s picture

Issue summary: View changes
scott_euser’s picture

I think before spending too much time on a direction would like to check in on the latest for Field Widget Actions in the AI module. Hoping we can leverage that somehow - its merge into the 1.2.x branch there.

I also wonder if while leveraging that, we'll see any design patterns there e.g. modal window or something with suggestions which could avoid a full form submission. With a lot of AI Initiative efforts happening there, aligning the UX as much as possible while keeping the suggestion levels and searching existing content from this module would great.

It may be hard however to avoid a page refresh unless we e.g. require the field to be Tagify like Drupal CMS uses (or at least remove support for autocomplete) otherwise e.g. an entity reference field that results in 3 references added yet only 1 field initially available doesn't work of course.

scott_euser’s picture

For reference for someone coming across this, this is the status quo UX of this module:

Link to the Gif from the module homepage

recrit’s picture

@scott_euser From what I can tell all of AI module's Content Suggesters and field actions for taxonomy still only use a text field to get the text used for the suggestion. The main advantage of the ai_auto_reference module is that it allows a rendered view mode to be used to get the text used for the suggestion. This is useful on sites that do not have a simple "body" field.

scott_euser’s picture

StatusFileSize
new1.29 MB

Oh yeah that's not what I mean - definitely the functionality here is important and provides quite a bit more value; more thinking of the UX changes only.

Had to dig a bit but this was an earlier release (not in stable version yet of AI module): https://drupal.slack.com/archives/C0803LX4536/p1751900254090099?thread_t... which is this mp4 video of using a button below an entity reference field

recrit’s picture

@scott_euser thanks for the video. That would be great if we had access to the updated entity object in the AJAX call.

scott_euser’s picture

Title: Improve UX to avoid data loss and support moderation » Implement 'Field Widget Actions' from AI core module to have modal window suggestions
Assigned: Unassigned » scott_euser
Issue summary: View changes
Status: Active » Needs work
StatusFileSize
new498.57 KB

Work in progress: screencast gif of work in progress opening modal and suggesting tags:

Screencast gif of work in progress opening modal and suggesting tags

scott_euser’s picture

Issue summary: View changes
recrit’s picture

@scott_euser thanks! That looks promising

scott_euser’s picture

StatusFileSize
new60.37 KB
new17.1 KB

Okay made some progress:

Steps (using the above #3563961 MR):

  1. Site builder adds FWA action to an entity reference field (working on supporting select, tagify, entity reference autocomplete, and entity reference autocomplete tags style)
  2. User clicks button:
    Screenshot of button
  3. Modal window appears:
    Screenshot of modal window
  4. Insert then fills in the parent node edit form <-- just this bit is almost there, but running out of time
scott_euser’s picture

Assigned: scott_euser » Unassigned
Status: Needs work » Fixed

Now merged into FWA module and merged here with test coverage

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • scott_euser committed b80f6d5a on 1.0.x
    feat: #3545461 Implement 'Field Widget Actions' from AI core module to...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.