Bug 154715 - "Edit Fields" for cross-reference fields should open on the type, format, and selection of the inserted field
Summary: "Edit Fields" for cross-reference fields should open on the type, format, and...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.3.0.4 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:24.8.0 target:24.2.3
Keywords: bibisected, bisected, regression
Depends on:
Blocks: Dialog-Remember-Settings Fields-Dialog
  Show dependency treegraph
 
Reported: 2023-04-08 12:13 UTC by sdc.blanco
Modified: 2024-04-08 15:44 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file (37.52 KB, application/vnd.oasis.opendocument.text)
2023-04-12 14:14 UTC, Buovjaga
Details
file to demonstrate problem (21.67 KB, application/vnd.oasis.opendocument.text)
2023-05-22 13:28 UTC, sdc.blanco
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sdc.blanco 2023-04-08 12:13:10 UTC
Basic problem:  Edit Field on an inserted cross-reference field opens to the last setting (Type, Selection and Format [in Refer using]) that was present in the Insert Field - Cross-reference tab (Ctrl+F2) dialog.

Expected:  The "edit field" dialog should open with the type, format, and selection of the field being edited.


To see problem:

1. Insert a couple of different kinds of cross-reference fields.

2. Open Insert Field dialog and set the Type, Selection and Format to some different settings, and "Close" the dialog (do not need to insert anything).

3.  Go back to one of the previously inserted fields, right-click, Edit Field.

Actual:  The setting in Step 2 is shown.
Expected:  The type, format, selection for the inserted field should be shown.

Also observed with:
Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 375f85f8518f49ce4381b6663f1e94fc02bacf93
Comment 1 Buovjaga 2023-04-12 14:13:41 UTC
Bibisected with Linux 43max to 333282478a956709e648427b412d90f90fc1437b
Related: fdo#75307 use the unique auto help id to identify tabpages
Comment 2 Buovjaga 2023-04-12 14:14:16 UTC
Created attachment 186617 [details]
Example file

Here is a silly test file for accelerated testing.
Comment 3 sdc.blanco 2023-04-12 21:48:00 UTC
Adding mention of enhancement request - bug 92688 (to remember the last used cross-reference type for "insert - field")  -- in case it involves the same underlying code.
Comment 4 Buovjaga 2023-04-13 05:37:28 UTC
(In reply to Buovjaga from comment #1)
> Bibisected with Linux 43max to 333282478a956709e648427b412d90f90fc1437b
> Related: fdo#75307 use the unique auto help id to identify tabpages

Just a note: I was looking at the type to be specific.
Comment 5 sdc.blanco 2023-04-28 07:57:16 UTC
(In reply to Buovjaga from comment #4)
> Just a note: I was looking at the type to be specific.
Will ask UXEval in relation to general issue.  Also, maybe this is an EasyHack
Comment 6 Heiko Tietze 2023-05-15 12:01:16 UTC
Basically it's desirable to open a tabbed dialog at the right place. But I wouldn't treat it as a huge mistake if that's not the fact in some situations since all tabs should have some close relation with the target.

When it comes to fields it might be a bit more difficult. If the first field is a cross-reference, followed by some docinformation, you wont be able to go from one to the other per edit field. If the fields are in the same context everything is updated as expected.

So yes in general, and please share a better STR for the actual problem.
Comment 7 sdc.blanco 2023-05-22 13:28:54 UTC
Created attachment 187437 [details]
file to demonstrate problem

(In reply to Heiko Tietze from comment #6)
> please share a better STR for the actual problem.
Demonstration file with instructions is attached, but any document with cross-reference fields can be used.

STR.
1. (to prepare test document, such as the attached, insert some cross-references with a variety of "type", "selection" and "refering using")

2.  Insert a new cross-reference (of any kind).

3.  Edit one of the previous cross-reference fields.

Actual:  When a previous cross-reference field is edited, then the "Type", "Selection", and "Refer using" corresponds to the last used choice.

Expected:  That "Type", "Selection", and "Refer using" corresponds to the values of the field being edited.
Comment 8 Heiko Tietze 2023-05-22 14:32:03 UTC
I insert Document-Sender and the this will be shown even for page number, for instance. This should be fixed. Not only the type of field (resp. tab) and the type should to be set according the actual field content but also the selection/format.

(Was wondering if we talk about Insert + Document, Insert + CrossRef... expecting the last choice again.)
Comment 9 sdc.blanco 2023-05-22 15:45:06 UTC
(In reply to Heiko Tietze from comment #8)
> (Was wondering if we talk about Insert + Document, Insert + CrossRef...
> expecting the last choice again.)
as noted in bug summary and in OP, the problem is in relation to fields entered from the Cross-references tab in the Insert Field dialog.

afacit, there are no problems with editing fields that were inserted from the Document or DocInformation tab (i.e., editing those fields opens to the correct properties for the field).
Comment 10 sdc.blanco 2023-05-22 16:01:04 UTC
Additional information

1.  Use the attached test file (attachment 187437 [details])

2.  place cursor at end of document, open Insert Field dialog (Ctrl+F2) - DocInformation tab.

3. Select "Type" "Revision number" and Insert.

4. Now edit any of the inserted cross-ref fields.

Actual and expected:  Field is opened with correct type, selection, refer using.

5.  Insert a new cross-reference field, then edit any existing cross-reference field.

Actual:  goes back to OP reported behavior (i.e., uses last selected type/selection/refer using).


==>  inserting a docinformation field seems to "update" something that allows appropriate editing of cross-reference fields, which gets lost again after inserting a new cross-reference field.
Comment 11 Caolán McNamara 2024-04-07 19:46:23 UTC
I think what the bisect identified is the commit that restored the ability of this dialog to read the previous saved settings used in that page.

What I think is then funky is that the page has "IsFieldEdit" which distinguishes between the page used to edit a field, vs the other case when its for inserting a field.

But even if "IsFieldEdit" is set, then it uses the saved settings to restore the last used settings. What is particularly off is

https://cgit.freedesktop.org/libreoffice/core/tree/sw/source/ui/fldui/fldref.cxx#n270

where we have: if( !IsRefresh() ) used twice, one inside the other, but if was true in the outer use, it would be true in the inner (all the way back to the initial commit). And IsRefresh is only true I think for the case of using the "next/back" button to go to edit another field.

Which suggests that if you click next and then back that you then get the right results

I think one of those IsRefresh was intended to be IsFieldEdit

https://gerrit.libreoffice.org/c/core/+/165876
Comment 12 Commit Notification 2024-04-08 12:40:55 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/db609a58df7be082de7d5a20a2a924789d6a64a1

Resolves: tdf#154715 don't use last-used field setting when editing field

It will be available in 24.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Caolán McNamara 2024-04-08 12:44:13 UTC
seems to do something more sensible now
Comment 14 Commit Notification 2024-04-08 15:44:51 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-24-2":

https://git.libreoffice.org/core/commit/843b3abd2ab05c66533b12ef6a4b155247f99e58

Resolves: tdf#154715 don't use last-used field setting when editing field

It will be available in 24.2.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.