- // we got a right click outside the text rect, default to action on the current url and not the pressed item
- Q_EMIT itemContextMenuRequested(m_pressedIndex.value(), screenPos);
+ // We have a right click outside the icon and text rect but within the hover highlight area
+ // but it is unclear if this means that a selection rectangle for an item was clicked or the background of the view.
+ if (m_selectionManager->selectedItems().contains(m_pressedIndex.value())) {
+ // The selection rectangle for an item was clicked
+ Q_EMIT itemContextMenuRequested(m_pressedIndex.value(), screenPos);
+ } else {
+ row->setHovered(false); // Removes the hover highlight so the context menu doesn't look like it applies to the row.
+ Q_EMIT viewContextMenuRequested(screenPos);
+ }