From 5759b25ca86732e21b6e9dd3d86d96f2ee757f4e Mon Sep 17 00:00:00 2001 From: martinfalisse Date: Sun, 6 Mar 2022 22:40:28 +0100 Subject: [PATCH] Spreadsheet: Handle case when drag-and-drop location is out of bounds When the drop location of a drag-and-drop operation is not valid, then don't continue with the drop_event. For example, if the ending location is the header row or header column, or is outside of the table, then should not continue. --- Userland/Applications/Spreadsheet/SpreadsheetView.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp index 9c1214e002..ac1a7604a5 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp @@ -246,9 +246,12 @@ void InfinitelyScrollableTableView::mouseup_event(GUI::MouseEvent& event) void InfinitelyScrollableTableView::drop_event(GUI::DropEvent& event) { - TableView::drop_event(event); m_is_dragging_for_cut = false; set_override_cursor(Gfx::StandardCursor::Arrow); + if (!index_at_event_position(event.position()).is_valid()) + return; + + TableView::drop_event(event); auto drop_index = index_at_event_position(event.position()); if (selection().size() > 0) { // Get top left index position of previous selection