Skip to content

Commit 29e46f4

Browse files
Bugfix FXIOS-12679 ⁃ Bookmarks, Downloads and Passwords all open history panel (backport #27689) (#27692)
Bugfix FXIOS-12679 ⁃ [Menu Redesign] Bookmarks, Downloads and Passwords all open history panel (#27689) FXIOS-12679 #27625 ⁃ Bookmarks, Downloads and Passwords all open history panel (cherry picked from commit 0d1e453) Co-authored-by: dicarobinho <[email protected]>
1 parent d18bd6d commit 29e46f4

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

BrowserKit/Sources/MenuKit/MenuRedesign/MenuRedesignTableView.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,13 @@ final class MenuRedesignTableView: UIView,
163163
didSelectRowAt indexPath: IndexPath
164164
) {
165165
tableView.deselectRow(at: indexPath, animated: false)
166+
let section = menuData[indexPath.section]
166167

167-
if let action = menuData[indexPath.section].options[indexPath.row].action {
168-
action()
168+
// We handle the actions for horizontalTabs, in MenuSquaresViewContentCell
169+
if !section.isHorizontalTabsSection {
170+
if let action = section.options[indexPath.row].action {
171+
action()
172+
}
169173
}
170174
}
171175

BrowserKit/Sources/MenuKit/MenuRedesign/MenuSquareCell.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ final class MenuSquareView: UIView, ThemeApplicable {
4040

4141
// MARK: - Properties
4242
var model: MenuElement?
43+
var cellTapCallback: (() -> Void)?
4344

4445
// MARK: - Initializers
4546
override init(frame: CGRect) {
4647
super.init(frame: frame)
4748
setupView()
49+
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap))
50+
self.addGestureRecognizer(tapGesture)
4851
}
4952

5053
required init?(coder aDecoder: NSCoder) {
@@ -103,6 +106,11 @@ final class MenuSquareView: UIView, ThemeApplicable {
103106
])
104107
}
105108

109+
@objc
110+
private func handleTap() {
111+
cellTapCallback?()
112+
}
113+
106114
// MARK: - Theme Applicable
107115
func applyTheme(theme: Theme) {
108116
backgroundColor = .clear

BrowserKit/Sources/MenuKit/MenuRedesign/MenuSquaresViewContentCell.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,26 @@ final class MenuSquaresViewContentCell: UITableViewCell, ReusableCell, ThemeAppl
2727
menuData = []
2828
super.init(style: style, reuseIdentifier: reuseIdentifier)
2929
setupUI()
30+
selectionStyle = .none
3031
}
3132

3233
required init?(coder: NSCoder) {
3334
fatalError("init(coder:) has not been implemented")
3435
}
3536

37+
// We override this method, for handling taps on MenuSquareView views
38+
// This may be a temporary fix
39+
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
40+
guard self.bounds.contains(point) else { return nil }
41+
for subview in contentStackView.arrangedSubviews {
42+
let convertedPoint = self.convert(point, to: subview)
43+
if let hitView = subview.hitTest(convertedPoint, with: event) {
44+
return hitView
45+
}
46+
}
47+
return super.hitTest(point, with: event)
48+
}
49+
3650
private func setupUI() {
3751
self.addSubview(contentStackView)
3852

@@ -46,13 +60,20 @@ final class MenuSquaresViewContentCell: UITableViewCell, ReusableCell, ThemeAppl
4660

4761
func reloadData(with data: [MenuSection]) {
4862
menuData = data
63+
setupHorizontalTabs()
64+
}
65+
66+
private func setupHorizontalTabs() {
4967
contentStackView.removeAllArrangedViews()
5068
guard let horizontalTabsSection else { return }
5169
for option in horizontalTabsSection.options {
5270
let squareView: MenuSquareView = .build { [weak self] view in
5371
guard let self else { return }
5472
view.configureCellWith(model: option)
5573
if let theme { view.applyTheme(theme: theme) }
74+
view.cellTapCallback = {
75+
option.action?()
76+
}
5677
}
5778
contentStackView.addArrangedSubview(squareView)
5879
}

0 commit comments

Comments
 (0)