Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit db21d4d

Browse files
authored
disable uncollapse when menu visible (#1413)
1 parent 9cb477c commit db21d4d

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

Classes/Issues/Comments/IssueCommentSectionController.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ IssueCommentDoubleTapDelegate {
2525
private let model: IssueDetailsModel
2626
private var hasBeenDeleted = false
2727
private let autocomplete: IssueCommentAutocomplete
28+
private var menuVisible = false
2829

2930
private lazy var webviewCache: WebviewCellHeightCache = {
3031
return WebviewCellHeightCache(sectionController: self)
@@ -131,7 +132,7 @@ IssueCommentDoubleTapDelegate {
131132

132133
@discardableResult
133134
private func uncollapse() -> Bool {
134-
guard collapsed else { return false }
135+
guard collapsed, !menuVisible else { return false }
135136
collapsed = false
136137
clearCollapseCells()
137138
update(animated: trueUnlessReduceMotionEnabled)
@@ -383,6 +384,14 @@ IssueCommentDoubleTapDelegate {
383384

384385
// MARK: IssueCommentReactionCellDelegate
385386

387+
func willShowMenu(cell: IssueCommentReactionCell) {
388+
menuVisible = true
389+
}
390+
391+
func didHideMenu(cell: IssueCommentReactionCell) {
392+
menuVisible = false
393+
}
394+
386395
func didAdd(cell: IssueCommentReactionCell, reaction: ReactionContent) {
387396
// don't add a reaction if already reacted
388397
guard let reactions = reactionMutation ?? self.object?.reactions,

Classes/Issues/Comments/Reactions/IssueCommentReactionCell.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import SnapKit
1111
import IGListKit
1212

1313
protocol IssueCommentReactionCellDelegate: class {
14+
func willShowMenu(cell: IssueCommentReactionCell)
15+
func didHideMenu(cell: IssueCommentReactionCell)
1416
func didAdd(cell: IssueCommentReactionCell, reaction: ReactionContent)
1517
func didRemove(cell: IssueCommentReactionCell, reaction: ReactionContent)
1618
}
@@ -62,6 +64,20 @@ UICollectionViewDelegateFlowLayout {
6264
make.left.equalTo(addButton.snp.right).offset(Styles.Sizes.columnSpacing)
6365
make.top.bottom.right.equalTo(contentView)
6466
}
67+
68+
let nc = NotificationCenter.default
69+
nc.addObserver(
70+
self,
71+
selector: #selector(onMenuControllerWillShow(notification:)),
72+
name: NSNotification.Name.UIMenuControllerWillShowMenu,
73+
object: nil
74+
)
75+
nc.addObserver(
76+
self,
77+
selector: #selector(onMenuControllerDidHide(notification:)),
78+
name: NSNotification.Name.UIMenuControllerDidHideMenu,
79+
object: nil
80+
)
6581
}
6682

6783
required init?(coder aDecoder: NSCoder) {
@@ -172,6 +188,16 @@ UICollectionViewDelegateFlowLayout {
172188
data.cell.iterate(add: add)
173189
}
174190

191+
// MARK: Notifications
192+
193+
@objc func onMenuControllerWillShow(notification: Notification) {
194+
delegate?.willShowMenu(cell: self)
195+
}
196+
197+
@objc func onMenuControllerDidHide(notification: Notification) {
198+
delegate?.didHideMenu(cell: self)
199+
}
200+
175201
// MARK: ListBindable
176202

177203
func bindViewModel(_ viewModel: Any) {

0 commit comments

Comments
 (0)