Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
RocketChat
Rocket.Chat.Fuselage
Commits
7085ea11
Commit
7085ea11
authored
Jan 22, 2021
by
Guilherme Gazzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Temporary fix for auto complete
parent
4e7fe6f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
packages/fuselage/src/components/AutoComplete/index.js
packages/fuselage/src/components/AutoComplete/index.js
+15
-11
packages/fuselage/src/components/Options/index.js
packages/fuselage/src/components/Options/index.js
+1
-1
No files found.
packages/fuselage/src/components/AutoComplete/index.js
View file @
7085ea11
...
...
@@ -2,7 +2,7 @@ import {
useMutableCallback
,
useResizeObserver
,
}
from
'
@rocket.chat/fuselage-hooks
'
;
import
React
,
{
useEffect
,
useRef
,
useMemo
}
from
'
react
'
;
import
React
,
{
useEffect
,
useRef
,
useMemo
,
useState
}
from
'
react
'
;
import
{
Box
,
PositionAnimated
,
AnimatedVisibility
}
from
'
../Box
'
;
import
Chip
from
'
../Chip
'
;
...
...
@@ -14,7 +14,6 @@ import { useCursor, Options } from '../Options';
const
Addon
=
(
props
)
=>
<
Box
rcx
-
autocomplete__addon
{...
props
}
/>
;
const
SelectedOptions
=
React
.
memo
((
props
)
=>
<
Chip
{...
props
}
/>
)
;
export
function
AutoComplete
({
value
,
filter
,
...
...
@@ -34,9 +33,14 @@ export function AutoComplete({
const
ref
=
useRef
();
const
[
selected
,
setSelected
]
=
useState
(()
=>
options
.
find
((
option
)
=>
getValue
(
option
)
===
value
)
);
const
selectByKeyboard
=
useMutableCallback
(([
value
])
=>
{
set
Filter
(
''
);
set
Selected
(
options
.
find
((
option
)
=>
getValue
(
option
)
===
value
)
);
onChange
(
value
);
setFilter
(
''
);
});
const
memoizedOptions
=
useMemo
(
...
...
@@ -53,6 +57,7 @@ export function AutoComplete({
]
=
useCursor
(
value
,
memoizedOptions
,
selectByKeyboard
);
const
onSelect
=
useMutableCallback
(([
value
])
=>
{
setSelected
(
options
.
find
((
option
)
=>
getValue
(
option
)
===
value
));
onChange
(
value
);
setFilter
(
''
);
hide
();
...
...
@@ -88,21 +93,20 @@ export function AutoComplete({
onBlur
=
{
hide
}
onFocus
=
{
show
}
onKeyDown
=
{
handleKeyDown
}
placeholder
=
{
placeholder
}
placeholder
=
{
(
optionsAreVisible
!==
AnimatedVisibility
.
HIDDEN
||
!
value
)
&&
placeholder
}
order
=
{
1
}
rcx
-
input
-
box
--
undecorated
value
=
{
filter
}
/
>
{
value
&&
optionsAreVisible
===
AnimatedVisibility
.
HIDDEN
&&
(
{
selected
&&
optionsAreVisible
===
AnimatedVisibility
.
HIDDEN
&&
(
<
RenderSelected
role
=
'
option
'
value
=
{
value
}
label
=
{
getLabel
(
options
.
find
((
option
)
=>
getValue
(
option
)
===
value
)
)}
children
=
{
getLabel
(
options
.
find
((
option
)
=>
getValue
(
option
)
===
value
)
)}
label
=
{
getLabel
(
selected
)}
children
=
{
getLabel
(
selected
)}
/
>
)}
<
/Margins
>
...
...
packages/fuselage/src/components/Options/index.js
View file @
7085ea11
...
...
@@ -190,4 +190,4 @@ export const useCursor = (initial, options, onChange) => {
return
[
cursor
,
handleKeyDown
,
handleKeyUp
,
reset
,
visibilityHandler
];
};
Options
.
AvatarSize
=
'
x2
8
'
;
Options
.
AvatarSize
=
'
x2
0
'
;
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