mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 14:14:55 +00:00
fix: set-tab! doesn't work on native module
This commit is contained in:
@@ -108,6 +108,17 @@ struct LiquidTabsRootView: View {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func selection(forId id: String) -> TabSelection? {
|
||||
if id == firstTab?.id { return .first }
|
||||
if id == secondTab?.id { return .second }
|
||||
if id == thirdTab?.id { return .third }
|
||||
if id == fourthTab?.id { return .fourth }
|
||||
if id == "search" { return .search }
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
private func initialSelection() -> TabSelection {
|
||||
if let id = store.selectedId {
|
||||
if id == firstTab?.id { return .first }
|
||||
@@ -239,6 +250,20 @@ struct LiquidTabsRootView: View {
|
||||
hackShowKeyboard = false
|
||||
}
|
||||
}
|
||||
.onChange(of: store.selectedId) { newId in
|
||||
guard let id = newId,
|
||||
let newSelection = selection(forId: id) else {
|
||||
return
|
||||
}
|
||||
|
||||
// If it's already selected, treat it as a no-op for programmatic changes
|
||||
// (if you want programmatic re-tap behavior, you could call handleRetap here)
|
||||
if newSelection == selectedTab {
|
||||
return
|
||||
}
|
||||
|
||||
selectedTab = newSelection
|
||||
}
|
||||
// Disable content animation on selection changes (only tab bar animates)
|
||||
.animation(nil, value: selectedTab)
|
||||
}
|
||||
|
||||
@@ -53,8 +53,12 @@
|
||||
|
||||
dismissing?
|
||||
(when (some? @mobile-state/*popup-data)
|
||||
(state/pub-event! [:mobile/clear-edit])
|
||||
(mobile-state/set-popup! nil))
|
||||
(let [quick-add? (mobile-state/quick-add-open?)
|
||||
current-tab @mobile-state/*tab]
|
||||
(state/pub-event! [:mobile/clear-edit])
|
||||
(mobile-state/set-popup! nil)
|
||||
(when (and current-tab quick-add?)
|
||||
(mobile-state/set-tab! current-tab))))
|
||||
|
||||
:else
|
||||
nil)))
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
[frontend.state :as state]))
|
||||
|
||||
(defonce *tab (atom "home"))
|
||||
(defn set-tab! [tab] (reset! *tab tab))
|
||||
(defn set-tab! [tab]
|
||||
(reset! *tab tab))
|
||||
(defn use-tab [] (r/use-atom *tab))
|
||||
(defonce *search-input (atom ""))
|
||||
(defn use-search-input []
|
||||
|
||||
Reference in New Issue
Block a user