Bug 157038 - Auto Spell Checker Prevents Cell Selection Right Click
Summary: Auto Spell Checker Prevents Cell Selection Right Click
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.4.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:24.2.0 target:7.6.3 target:7.5.8
Keywords: bibisected, bisected, regression
: 155621 (view as bug list)
Depends on:
Blocks: Cell-Selection
  Show dependency treegraph
 
Reported: 2023-08-31 15:24 UTC by crxssi
Modified: 2023-10-05 14:36 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
157038_rightClickLosesSelect.ods: right-clicking yellow-highlighted squares loses selection (15.81 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-09-29 18:59 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description crxssi 2023-08-31 15:24:58 UTC
There is a recent bug where the user cannot right click on a selected cells range   if any cell to the left of the selection contains a misspelled word when Automatic Spell Checking is on.  Right clicking on the selection will just unselect what was selected before it shows the context menu.

How to reproduce:

* Start a new spreadsheet
* Enter a misspelled word in cells B2 through B10
* Verify those cells contain data showing red underlines
* Select the range C2 through C10 with the mouse so they are highlighted
* Right click on the selected range.
* Note the selection immediately disappears

It only happens with misspelled words in the immediate left cells to what is selected.

Workaround:  Turn off auto spell checker

Bug PRESENT in:  7.4.5, 7.5.5

Bug NOT present in:  4.2.6, 6.3.6, 7.3.2
Comment 1 crxssi 2023-08-31 19:53:00 UTC
Update:

It doesn't matter how far left the misspelled word cells are, you can't select and right click a range anywhere to the right of those cells.  Right clicking on the range only fails if ALL the cells have a corresponding misspelled words in cells to the left.

Bug is also present in 7.6.0
Comment 2 crxssi 2023-09-05 14:13:14 UTC
Bug also present in 7.5.6
Comment 3 Kira Tubo 2023-09-07 22:45:10 UTC
Reproduced in daily master build

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 9a37652b79001bf5208841b9221dee851b9b6d0f
CPU threads: 6; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded
Comment 4 ady 2023-09-10 16:46:10 UTC
I think the problem is where exactly within the cell/range you right-click.

When the cell (containing a misspelled word) is wider than its content, you can right-click _after_ the text inside the cell; meaning, the location where you right-click is to the right side of the content. In that case, the cell's context menu indeed is displayed.

OTOH, when the location of the right-click is on the text itself, the context menu that is displayed is not for the cell but for the spelling features (e.g. suggestions of similar words, "ignore"...).

This behavior makes it more difficult for users to display the cell's context menu when:
* the cell is not wider than its (text) context; or,
* the (text) content is aligned to the right/end of the cell.

I have not tested RTL cases, so it is possible that when I mentioned "right" in this comment, the actual meaning would be different in such cases (e.g. RTL worksheet layout; RTL words; right-alignment of cell's content; click on the right after the cell's content; and all sorts of combinations).
Comment 5 crxssi 2023-09-11 15:27:01 UTC
(In reply to ady from comment #4)
> I think the problem is where exactly within the cell/range you right-click.
> 
> When the cell (containing a misspelled word) is wider than its content, you
> can right-click _after_ the text inside the cell; meaning, the location
> where you right-click is to the right side of the content. In that case, the
> cell's context menu indeed is displayed.

I think you are misunderstanding the problem behavior.  It is not about clicking in the cells that contain misspelled words.  It is about selecting a range of cells in a column AFTER that column (not containing the column with misspelled words), and then right clicking and not being able to get the menu in that selected range.
Comment 6 ady 2023-09-11 16:36:06 UTC
(In reply to crxssi from comment #5)
>  It is about selecting
> a range of cells in a column AFTER that column (not containing the column
> with misspelled words), and then right clicking and not being able to get
> the menu in that selected range.

In such case I do get the context menu, but the selection is not kept; only the cell on which I right-click has the focus (and its context menu), and no cell/range remains selected (LO 7.6.0.3). This does not happen when the selected range is on the left-side of the cells containing misspelled words.

STR:
1. (Spelling language: English)
 B1: Une
 B2: wo
 B3: tre
2. Select A1:A3 and right-click on A1 > no problem.
3. Select C1:C3 and right-click on C1 > selection lost.
4. Select C1:C3 and right-click on C3 > selection lost.
5. Select C1:C4 and right-click on C4 > no problem.
6. Select C3:C4 and right-click on C4 > no problem.
7. Edit B1:B3 as follows:
 B1: One
 B2: two
 B3: three
8. Repeat steps 2. to 6. > no problem.
Comment 7 ady 2023-09-11 16:46:33 UTC
I can repro the STR from comment 6 in LO 7.4.3.2 but not in LO 7.3.
Comment 8 crxssi 2023-09-11 17:34:18 UTC
(In reply to ady from comment #6)
> (In reply to crxssi from comment #5)
> >  It is about selecting
> > a range of cells in a column AFTER that column (not containing the column
> > with misspelled words), and then right clicking and not being able to get
> > the menu in that selected range.
> 
> In such case I do get the context menu, but the selection is not kept;

Sorry, my original description is correct (comment 0).  The selection disappears and the context menu does appear but isn't useful because the selection is gone :)
Comment 9 Heiko Tietze 2023-09-13 08:53:28 UTC
Confirming with 

Version: 7.6.0.3 (X86_64) / LibreOffice Community
Build ID: 60(Build:3)
CPU threads: 8; OS: Linux 6.5; UI render: default; VCL: kf5 (cairo+xcb)
Locale: de-DE (en_US.UTF-8); UI: en-US
7.6.0-3
Calc: threaded

It depends on whether the cell left off the clicked has a spelling error. Interestingly, for RTL sheets it happens on the opposite side but clicking jumps into the cell.
Comment 10 Kira Tubo 2023-09-17 06:24:48 UTC
*** Bug 155621 has been marked as a duplicate of this bug. ***
Comment 11 ady 2023-09-17 16:21:18 UTC
(In reply to Heiko Tietze from comment #9)
> Interestingly, for RTL sheets it happens on the opposite side but clicking
> jumps into the cell.

That might be a separate issue. See comment 4 as an example of different results depending on where exactly the user clicks within a cell. I could be wrong, as I have not tested this report in RTL cases.
Comment 12 Kira Tubo 2023-09-18 00:29:44 UTC
Bibisected repository win64-7.4. 

Regression occurring at: https://git.libreoffice.org/core/+/cf18038c66075f7a18d89e47f3a2ab1a5bf7c4fd

Note that the commit was made to fix Bug 81894.


commit cf18038c66075f7a18d89e47f3a2ab1a5bf7c4fd	[log]
author	Justin Luth <justin_luth@sil.org>	Sat Feb 19 20:22:23 2022 +0200
committer	Eike Rathke <erack@redhat.com>	Fri Feb 25 15:22:32 2022 +0100
tree 2032074d415fd06b060f1e4f41be3aa99d49c92a
parent 6c49b4290955ef1b3a502b4e5e223a4fd5573683 [diff]

 c87abe4ee3766a65a553ba1ea513f0b5bf774c92 is the first bad commit
commit c87abe4ee3766a65a553ba1ea513f0b5bf774c92
Author: Norbert Thiebaud <nthiebaud@gmail.com>
Date:   Fri Feb 25 06:58:41 2022 -0800

    source cf18038c66075f7a18d89e47f3a2ab1a5bf7c4fd
Comment 13 ady 2023-09-18 01:57:17 UTC
(In reply to Kira Tubo from comment #12)
> Bibisected repository win64-7.4. 
> 
> Regression occurring at:
> https://git.libreoffice.org/core/+/cf18038c66075f7a18d89e47f3a2ab1a5bf7c4fd
> 
> Note that the commit was made to fix Bug 81894.

CC'ing Justin.
Comment 14 Justin L 2023-09-29 18:59:15 UTC
Created attachment 189896 [details]
157038_rightClickLosesSelect.ods: right-clicking yellow-highlighted squares loses selection

First of all, this is a real bug. Thanks for reporting it.

Steps to reproduce:
-select some cells in column C (including some yellow cells)
-right-click the selection somewhere over a yellow cell
-notice that the selection existing selection is lost, and only that cell is active.

This is a tricky situation. It is ONLY happening with right-clicks in empty cells. The point here is that an earlier cell has spelling mistakes in it, and in theory that text COULD spill over into this empty cell and be displayed there (since there is no text to "hide" it). [example in the attachment]
Comment 15 Justin L 2023-09-29 21:00:26 UTC
The issue is with SelectForContextMenu.
Previously, the deleted function (IsSpellErrorAtPos) was returning false - even on some occasions when it should have returned true. So the cell-under-the-cursor was sent to the function, and it recognized that it was IsCellMarked(nCellX, nCellY), and so it exited without changing the selection.

Now the cell is selected, and when the spell dialog returns false, the next call to SelectForContextMenu no longer considers the cell under the cursor to be marked.

So the key to this is probably capturing the mark status and reverting if !bDone. But so far I don't have any luck guessing how to accomplish this.
Comment 16 Commit Notification 2023-09-30 14:24:57 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4cf4516bac88fb8f58743e6ae68eab0393059d7f

tdf#157038 sc: avoid spell-check dialog from outside selection

It will be available in 24.2.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 17 Commit Notification 2023-10-03 09:53:55 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

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

tdf#157038 sc: avoid spell-check dialog from outside selection

It will be available in 7.6.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.
Comment 18 Commit Notification 2023-10-05 09:36:05 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/0e87e8a810b93a740beff63ceb1e40d2e5271acf

tdf#157038 sc: avoid spell-check dialog from outside selection

It will be available in 7.5.8.

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.