Bug 147697 - Wrong field or value inserted by drag and drop from 'Data Sources' when table preview needs to scroll
Summary: Wrong field or value inserted by drag and drop from 'Data Sources' when table...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
4.3.0.4 release
Hardware: All All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Data-SourceView
  Show dependency treegraph
 
Reported: 2022-02-28 15:27 UTC by jncressey
Modified: 2022-12-20 11:43 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
minimal example to use when following reproduction steps (4.68 KB, application/x-zip-compressed)
2022-02-28 15:28 UTC, jncressey
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jncressey 2022-02-28 15:27:24 UTC
Description:
Affects the UI in Writer, Calc, Math, Impress, and Draw.

The 'Data Sources' panel can be used to insert fields into documents for creating a mail merge and into spreadsheets as form controls by dragging their header onto the document or spreadsheet.

The problem is when the field that the user wants to insert has its column half visible, and half off the right-hand edge of the table preview.

After the drag, the correct column becomes highlighted, but the wrong field is inserted, which can confuse.

The 'Data Sources' panel can also be used to insert the actual values from a table by dragging the value. If you drag from a value under the same conditions, again the wrong field is used; so the wrong value is inserted. In addition to Writer and Calc, inserting actual values affects Math, Impress, and Draw. (The 'Data Sources' panel can be shown in Math, Impress, and Draw by pressing ctrl+shift+f4 despite note appearing in the menu bar)

An easy workaround is to scroll the column into view before dragging it onto the document or spreadsheet.

Steps to Reproduce:
1. Download and extract 'Database.odb', 'Spreadsheet.ods', and 'Text.odt' from 'minimal-example.zip'.
   
   - 'Database.odb' has a single table 'Table1' with 30 fields with random data over a few records.
   - 'Spreadsheet.ods' is a new empty spreadsheet.
   - 'Text.odt' is a new empty document.

2. Register 'Database.odb' as a database with the name 'Database'.
   
   1. Open LibreOffice
   2. Choose Tools - Options - LibreOffice Base - Databases.
   3. Click 'New' and select the database file.
   4. Press Apply or OK

3. Open 'Text.odt' in LibreOffice Writer, or open 'Spreadsheet.ods' in LibreOffice Calc.

4. Show the Data Sources pane. (menu bar - View - Data Sources) or (ctrl+shift+f4)

5. In the Data Sources pane, expand the database 'Database', and expand 'Tables'.

6. Click on 'Table1'.

7. Resize the column of 'field1' in the preview such that, while field1 is showing, the column for 'field2' is half showing and half clipped over the righthand edge.

8. Scroll the preview to entirely show 'field2'.

9. If, while 'field2' is in view, the last field ends before the righthand edge, resize some columns after 'field2' such that the table does span the whole width of the pane while 'field2' is in view.

10. Scroll the preview back to show 'field1' and part of 'field2'.

11. Click on a value in the column of 'field1'. (So that no columns are selected. If the column for 'field2' is highlighted, then the table doesn't scroll, so the strange behaviour doesn't happen.)

12. Drag and hold (don't let go yet) from the heading of 'field2' onto the document or spreadsheet.
    
    - observe the column of 'field2' becomes highlighted
    - observe the table scrolls so that 'field2' is entirely in view.

13. Release the drag onto the document or spreadsheet.
    
    - observe that 'field2' is still highlighted on the table view.
    - observe that the field that has been inserted is not 'field2'. 
    - observe that the field which does appear inserted in the document is whichever field has been scrolled to where on the screen you started dragging from in step 10. 

14. To repeat, go to step 10. Or go to step 3 to try with the other document or spreadsheet.

Actual Results:
The inserted field doesn't match the column which was dragged and becomes highlighted during the action, which can be confusing.

- The behaviour is easiest observed if 'field2' has a small width such that after the scroll, it has no overlap with where you could have started dragging from.
- If you skipped step 9, and the table ends before the point that you started dragging from, then no field is inserted into the document
- If you drag a value from 'field2' instead of the column heading, the wrong field is again used. It inserts the value from the wrong column. However, there is no highlighting of 'field2' in this action, so the inconsistency is more difficult to see. 

Expected Results:
The field that is inserted should be what the user started dragging.


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.1.8.1 (x64) / LibreOffice Community
Build ID: e1f30c802c3269a1d052614453f260e49458c82c
CPU threads: 8; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: en-GB (en_GB); UI: en-GB
Calc: threaded
Comment 1 jncressey 2022-02-28 15:28:07 UTC
Created attachment 178584 [details]
minimal example to use when following reproduction steps
Comment 2 jncressey 2022-02-28 15:38:08 UTC
The observation under step 13 should instead reference where the user started dragging in step 12, not 10.
Comment 3 Buovjaga 2022-12-20 11:43:31 UTC
Reproduced, already in 4.3.0

Version: 7.5.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 9cd0f4c2d25462feba0ffcbd906c199273821243
CPU threads: 8; OS: Linux 6.0; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded