From b6317e7db9ae2da9b0d1d8fc97603687ccdd0d2e Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 3 Nov 2023 16:50:05 -0400 Subject: [PATCH] Enable long-press in search --- .../ViewRelated/Pages/PageListViewController.swift | 3 ++- .../Post/Search/PostSearchViewController.swift | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift b/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift index 5edfbcd6784e..a3edb0734b96 100644 --- a/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift +++ b/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift @@ -319,7 +319,8 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe } func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { - UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in + guard indexPath.section == Section.pages.rawValue else { return nil } + return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in guard let self else { return nil } let page = self.pages[indexPath.row] let cell = self.tableView.cellForRow(at: indexPath) diff --git a/WordPress/Classes/ViewRelated/Post/Search/PostSearchViewController.swift b/WordPress/Classes/ViewRelated/Post/Search/PostSearchViewController.swift index 6116e1542718..e4224f084377 100644 --- a/WordPress/Classes/ViewRelated/Post/Search/PostSearchViewController.swift +++ b/WordPress/Classes/ViewRelated/Post/Search/PostSearchViewController.swift @@ -182,6 +182,16 @@ final class PostSearchViewController: UIViewController, UITableViewDelegate, UIS } } + func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { + guard indexPath.section == SectionID.posts.rawValue else { return nil } + return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in + guard let self, let delegate = self.delegate else { return nil } + let post = self.viewModel.posts[indexPath.row] + let cell = self.tableView.cellForRow(at: indexPath) + return AbstractPostHelper.makeContextMenu(for: post, presentingView: cell, delegate: delegate) + } + } + func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { guard let delegate, indexPath.section == SectionID.posts.rawValue else { return nil } let actions = AbstractPostHelper.makeLeadingContextualActions(for: viewModel.posts[indexPath.row], delegate: delegate)