Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
139
Issues
139
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
177603e8
Verified
Commit
177603e8
authored
Nov 22, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[reactix] better focus function, more triggers removal
parent
e52647f9
Pipeline
#7030
passed with stages
in 15 minutes and 27 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
21 deletions
+13
-21
Reactix.js
src/Gargantext/Utils/Reactix.js
+8
-0
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+5
-21
No files found.
src/Gargantext/Utils/Reactix.js
View file @
177603e8
...
...
@@ -54,6 +54,14 @@ export function _keyCode(e) {
return
e
.
which
||
e
.
keyCode
;
}
export
function
_implFocus
(
nel
)
{
if
(
nel
===
null
)
{
return
;
}
else
{
nel
.
focus
();
}
}
export
function
_scrollIntoView
(
el
)
{
return
el
.
scrollIntoView
({
behavior
:
'smooth'
,
...
...
src/Gargantext/Utils/Reactix.purs
View file @
177603e8
...
...
@@ -494,10 +494,12 @@ foreign import _setCookie :: EffectFn1 String Unit
setCookie :: String -> Effect Unit
setCookie = runEffectFn1 _setCookie
foreign import _implFocus :: EffectFn1 (Nullable R.Element) Unit
focus :: Nullable R.Element -> Effect Unit
focus nEl = case toMaybe nEl of
Nothing -> pure unit
Just el -> el ... "focus" $ []
focus nel = runEffectFn1 _implFocus nel
foreign import _scrollIntoView :: EffectFn1 DOM.Element Unit
...
...
@@ -509,24 +511,6 @@ setIndeterminateCheckbox :: R.Element -> Boolean -> Effect R.Element
setIndeterminateCheckbox el val = pure $ (el .= "indeterminate") val
-- A "trigger" is a ref to a function which is used to make changes without
-- modifying too much DOM.
-- This is to escape passing explicit state to nested child components.
type Trigger a = R.Ref (Maybe (a -> Effect Unit))
callTrigger :: forall a. Trigger a -> a -> Effect Unit
callTrigger tRef arg = case R.readRef tRef of
Nothing -> do
log2 "[callTrigger] trigger is empty" tRef
pure unit
Just t -> t arg
setTrigger :: forall a. Trigger a -> (a -> Effect Unit) -> Effect Unit
setTrigger tRef fun = R.setRef tRef $ Just fun
clearTrigger :: forall a. Trigger a -> Effect Unit
clearTrigger tRef = R.setRef tRef Nothing
type Rect =
( x :: Number
, y :: Number
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment