mirror of
https://github.com/penpot/penpot.git
synced 2025-05-09 03:05:58 +02:00
Merge pull request #1933 from penpot/palba-fix-file-menu-not-accessible
🐛 Fix menu file not accessible in certain conditions
This commit is contained in:
commit
3604d0cfc9
2 changed files with 29 additions and 21 deletions
|
@ -11,6 +11,8 @@
|
||||||
- Multiple team invitations on onboarding [Taiga #3084](https://tree.taiga.io/project/penpot/us/3084)
|
- Multiple team invitations on onboarding [Taiga #3084](https://tree.taiga.io/project/penpot/us/3084)
|
||||||
|
|
||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
|
- Fix menu file not accessible in certain conditions [Taiga #3385](https://tree.taiga.io/project/penpot/issue/3385)
|
||||||
|
|
||||||
### :arrow_up: Deps updates
|
### :arrow_up: Deps updates
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
|
|
||||||
|
|
|
@ -35,39 +35,45 @@
|
||||||
route (mf/deref refs/route)
|
route (mf/deref refs/route)
|
||||||
in-dashboard? (= :dashboard-projects (:name (:data route)))
|
in-dashboard? (= :dashboard-projects (:name (:data route)))
|
||||||
|
|
||||||
local (mf/use-state {:offset 0
|
local (mf/use-state {:offset-y 0
|
||||||
|
:offset-x 0
|
||||||
:levels nil})
|
:levels nil})
|
||||||
|
|
||||||
on-local-close
|
on-local-close
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(fn []
|
(fn []
|
||||||
(swap! local assoc :levels [{:parent-option nil
|
(swap! local assoc :levels [{:parent-option nil
|
||||||
:options options}])
|
:options options}])
|
||||||
(on-close)))
|
(on-close)))
|
||||||
|
|
||||||
check-menu-offscreen
|
check-menu-offscreen
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps top (:offset @local))
|
(mf/deps top (:offset-y @local) left (:offset-x @local))
|
||||||
(fn [node]
|
(fn [node]
|
||||||
(when (some? node)
|
(when (some? node)
|
||||||
(let [{node-height :height} (dom/get-bounding-rect node)
|
(let [bounding_rect (dom/get-bounding-rect node)
|
||||||
{window-height :height} (dom/get-window-size)
|
window_size (dom/get-window-size)
|
||||||
target-offset (if (> (+ top node-height) window-height)
|
{node-height :height node-width :width} bounding_rect
|
||||||
|
{window-height :height window-width :width} window_size
|
||||||
|
target-offset-y (if (> (+ top node-height) window-height)
|
||||||
(- node-height)
|
(- node-height)
|
||||||
0)]
|
0)
|
||||||
|
target-offset-x (if (> (+ left node-width) window-width)
|
||||||
|
(- node-width)
|
||||||
|
0)]
|
||||||
|
|
||||||
(when (not= target-offset (:offset @local))
|
(when (or (not= target-offset-y (:offset-y @local)) (not= target-offset-x (:offset-x @local)))
|
||||||
(swap! local assoc :offset target-offset))))))
|
(swap! local assoc :offset-y target-offset-y :offset-x target-offset-x))))))
|
||||||
|
|
||||||
enter-submenu
|
enter-submenu
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps options)
|
(mf/deps options)
|
||||||
(fn [option-name sub-options]
|
(fn [option-name sub-options]
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(swap! local update :levels
|
(swap! local update :levels
|
||||||
conj {:parent-option option-name
|
conj {:parent-option option-name
|
||||||
:options sub-options}))))
|
:options sub-options}))))
|
||||||
|
|
||||||
exit-submenu
|
exit-submenu
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
|
@ -87,8 +93,8 @@
|
||||||
[:div.context-menu {:class (dom/classnames :is-open open?
|
[:div.context-menu {:class (dom/classnames :is-open open?
|
||||||
:fixed fixed?
|
:fixed fixed?
|
||||||
:is-selectable is-selectable)
|
:is-selectable is-selectable)
|
||||||
:style {:top (+ top (:offset @local))
|
:style {:top (+ top (:offset-y @local))
|
||||||
:left left}}
|
:left (+ left (:offset-x @local))}}
|
||||||
(let [level (-> @local :levels peek)]
|
(let [level (-> @local :levels peek)]
|
||||||
[:ul.context-menu-items {:class (dom/classnames :min-width min-width?)
|
[:ul.context-menu-items {:class (dom/classnames :min-width min-width?)
|
||||||
:ref check-menu-offscreen}
|
:ref check-menu-offscreen}
|
||||||
|
|
Loading…
Add table
Reference in a new issue