Problem/Motivation

This is a portion of #2900409: [Meta] Improve UI of Reference field settings form, separated out after comment #133.

There is a core UX concept called progressive disclosure, where you hide complexity until the point at which you actually need it. It would be good if the field settings form for Entity Reference fields used this concept.

Proposed resolution

Hide the Sort options select in the Entity Reference field settings dialog unless one or more bundles is selected.

Remaining tasks

None

User interface changes

Hide the Sort options select in the Entity Reference field settings dialog unless one or more bundles is selected.

Here is a screenshot before applying the patch. No bundles are selected, but the "Sort by" select list is visible:

screenshot without patch

After applying the patch, the select list is hidden when no bundles are selected:

screenshot with patch, no bundles selected


screenshot with the patch, one bundle selected

API changes

None.

Data model changes

None.

Release notes snippet

Probably not necessary, a small UX improvement.

Comments

jhodgdon created an issue. See original summary.

benjifisher’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new3.09 KB

I think this patch should do it.

Do we have the right component for this issue (Field UI module)? The changed behavior is under core/lib/Drupal/Core/Entity, and the test is in the Field module. I think this is a symptom of a broader problem.

benjifisher’s picture

Issue summary: View changes
StatusFileSize
new57.77 KB
new50.29 KB
new58.15 KB

I am adding some screenshots to the issue description.

Status: Needs review » Needs work

The last submitted patch, 2: 3089523-2.patch, failed testing. View results

jhodgdon’s picture

Looks like some additional test fixes are needed...

benjifisher’s picture

Status: Needs work » Needs review
StatusFileSize
new1.06 KB
new3.21 KB

Funny, the test passed locally (in the UI). Maybe this is the right way to check for visibility.

Status: Needs review » Needs work

The last submitted patch, 6: 3089523-6.patch, failed testing. View results

benjifisher’s picture

Status: Needs work » Needs review

The first test of the patch in #6 failed on a different test. I triggered a retest. Since the retest passed, I am moving this issue back to NR.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

We should probably make sure there is a Random Test Failure issue about that failed test, as it is most likely a test that will fail sometimes due to timing -- at least the error looks like that could be the case (something not on the screen yet from Ajax I suspect). Let's see...

Hm... I guess it was probably actually an infrastructure glitch, because one of the errors in that test run was "Failed to start the web server". So I think we should let it go.

Anyway, the code, test, and screenshots look good to me. However, I did some manual testing, and ... oh never mind. I noticed #3089525: Sort options should correspond to bundles selected for entity reference field settings but that is a separate issue. So, this is working fine in manual testing: the Sort options list is hidden when no bundles are selected, and visible if at least one option is selected.

benjifisher’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for looking into the test failure. I know I should have done that, but I did not have time/patience/energy.

benjifisher’s picture

Status: Needs work » Reviewed & tested by the community

Once again, I left an issue open in a browser tab, forgot to force-reload, and accidentally changed the issue status.

Back to RTBC as in #9.

  • lauriii committed 7553451 on 9.0.x
    Issue #3089523 by benjifisher, jhodgdon: Use progressive disclosure to...

  • lauriii committed 45b25f0 on 8.9.x
    Issue #3089523 by benjifisher, jhodgdon: Use progressive disclosure to...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Tested this manually and everything seemed fine. Also double-checked that this doesn't cause any regressions for non-JavaScript users and as expected, everything worked fine.

Committed 7553451 and pushed to 9.0.x and 8.9.x. Thanks!

lauriii’s picture

jhodgdon’s picture

Status: Fixed » Patch (to be ported)

Setting status to "To be ported" like other parts of #2900409: [Meta] Improve UI of Reference field settings form to see if we want it in 8.8 too.

lauriii’s picture

This doesn't feel very risky but I guess the biggest risk I can think of is some projects tests breaking. I would love to hear what other people think about backporting this.

alison’s picture

Backporting would be sweet, if it's practical for folks to implement!

harpreet16’s picture

Assigned: Unassigned » harpreet16
StatusFileSize
new3.24 KB

Note: This patch is applicable for 8.8.x version after https://www.drupal.org/project/drupal/issues/3089521 is applied.
@lauriii pls let me know if any other update is needed. Tested on local setup. Works fine for me.

harpreet16’s picture

harpreet16’s picture

Assigned: harpreet16 » Unassigned
Status: Patch (to be ported) » Needs review
lauriii’s picture

Status: Needs review » Fixed

It's getting late for us to backport this to 8.8.x. Marking this as fixed since this has been committed to 8.9.x already.

Status: Fixed » Closed (fixed)

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