dspace-angular icon indicating copy to clipboard operation
dspace-angular copied to clipboard

Edit Item: Remove Zero Width Spaces in field names so they can be copied

Open alawvt opened this issue 2 years ago • 4 comments

Describe the bug In Edit Item > Metadata, one must enter a Field Name in the left textbox. In DSpace 6 XMLUI, e.g., https://demo.dspace.org/xmlui/admin/item?administrative-continue=744b65332f2c4f2c6338636b1a7e785468161f2b&submit_metadata, one uses the dropdown box, which avoids having to type the field name. Also, the default field name in the "Add new metadata" form is that of the last new field submitted. This saves time for repetitive fields such as multiple authors or advisors. DSpace6_XMLUI_edit_metadata

In DSpace 7, , e.g. https://demo7.dspace.org/items/03731881-2185-4baf-a6a8-1438a4d29dc8/edit/metadata), one must type at least a couple letters for autocomplete of the field name. To avoid typing, I tried copying the field name from the Field Name in the line below. It gave the "Please choose a valid metadata field" error message. It turns out that the field name that I copied from the field below contains a Zero Width Space [Unicode U+200B, UTF-8 E2808B] after each period, dc.​contributor.​author. If these Zero Width Spaces could be removed then copying and pasting would work. DSpace7_edit_metadata

Much of repository work is repetitive. If an operation can be done with just clicking or just typing, it will be less tiring than requiring both per task.

To Reproduce Steps to reproduce the behavior:

  1. Do this
  2. Then this...

Expected behavior A clear and concise description of what you expected to happen.

Related work Link to any related tickets or PRs here.

alawvt avatar Aug 08 '22 20:08 alawvt

@alawvt : Wow, that must have been difficult to debug!

Strangely though, it appears this change is purposeful. I'm not sure why, but we have code here that replaces the periods with .​: https://github.com/DSpace/dspace-angular/blob/main/src/app/item-page/edit-item-page/item-metadata/edit-in-place-field/edit-in-place-field.component.html#L4

I'm not sure why we'd be doing that though, as it doesn't make sense to me.

@LotteHofstede or @artlowel : Do you happen to know why we are adding in a Zero Width Space between the periods on this page? It appears it was originally added in #362 (a long time ago), and it's not clear if it's required or if we can simply remove it.

tdonohue avatar Aug 23 '22 20:08 tdonohue

Ha ha. Yes, it took a few minutes but I've had plenty of practice. (Mac Character Viewer has a search box in which one can paste mystery characters. It works pretty well.)

alawvt avatar Aug 23 '22 20:08 alawvt

@LotteHofstede or @artlowel : Do you happen to know why we are adding in a Zero Width Space between the periods on this page? It appears it was originally added in #362 (a long time ago), and it's not clear if it's required or if we can simply remove it.

@tdonohue The Zero Width Space character implies that if a line break is necessary to fit inside the table cell, it will break on the Zero Width Space. So in our case, right after the period, instead of in the middle of the metadata field's element/qualifier.

LotteHofstede avatar Aug 24 '22 09:08 LotteHofstede

@LotteHofstede : Thanks for that explanation.

I suspect here we may need to make a decision though on whether a Zero Width Space should be used in this field. I admit, I've previously hit this same issue as @alawvt (without even realizing the cause). So, I don't think it's unexpected that a user would copy the field name into a newly added field.... which doesn't work as the copied field name will include (invisible) Zero Width Spaces.

I'd personally lean towards removing these Zero Width Spaces from the display. But, that might mean that the table cell will wrap text in an odd manner on smaller displays.

For now, I'll move this over to our 7.4 board, but leave it as low priority until we determine if this is a common issue. I suspect the priority may need bumping up at some point, but I'd like to hear more from others first.

tdonohue avatar Aug 24 '22 14:08 tdonohue

Closing, this appears to be fixed now. It is no longer reproducible on https://demo.dspace.org (which is running the latest 7.6.x code, pre-7.6.2). It's unclear to me where/when this was fixed

tdonohue avatar Apr 24 '24 14:04 tdonohue