Skip to content

Commit

Permalink
Remove Salt labs input usage
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding authored and DavieReid committed Jan 23, 2024
1 parent 59658fd commit 45edb01
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import {
RangeSelection,
SELECTION_CHANGE_COMMAND
} from 'lexical';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import React, { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';
import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
import { useFloatingUI } from '@salt-ds/core';
import { Input } from '@salt-ds/lab';
import { useFloatingUI, Input } from '@salt-ds/core';
import { useDismiss, useInteractions } from '@floating-ui/react';

import styles from './LinkEditor.css';
Expand Down Expand Up @@ -119,7 +118,7 @@ export function LinkEditor() {
endAdornment={<SaveAdornment onSave={handleSave} />}
ref={inputRef}
value={linkUrl}
onChange={event => {
onChange={(event: ChangeEvent<HTMLInputElement>) => {
setLinkUrl(event.target.value);
}}
onKeyDown={event => {
Expand Down
29 changes: 19 additions & 10 deletions packages/site-components/src/SearchInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { FormField, SearchInput as SaltSearchInput } from '@salt-ds/lab';
import { Input, Button } from '@salt-ds/core';
import { Icon } from '@jpmorganchase/mosaic-components';
import { useSearchData } from './useSearchData';

import { performSearch } from './searchUtils';
import { ResultsList } from './Results';
import type { SearchResults } from './Results';
Expand All @@ -14,6 +14,7 @@ export function SearchInput() {
const [listVisibility, setListVisibility] = useState(false);

const wrapperRef = useRef<HTMLDivElement | null>(null);
const inputRef = useRef<HTMLInputElement>(null);

const handleSearch = e => {
setSearchTerm(e.target.value);
Expand All @@ -25,6 +26,7 @@ export function SearchInput() {
const handleClear = useCallback(() => {
setSearchTerm('');
setSearchResults([]);
inputRef.current?.focus();
}, [searchTerm, searchResults]);

const handleInputFocus = () => {
Expand Down Expand Up @@ -55,14 +57,21 @@ export function SearchInput() {

return (
<div className={styles.root} ref={wrapperRef}>
<FormField style={{ minWidth: 200 }}>
<SaltSearchInput
value={searchTerm}
onChange={handleSearch}
onClear={handleClear}
onFocus={handleInputFocus}
/>
</FormField>
<Input
aria-label="Search"
startAdornment={<Icon name="search" />}
endAdornment={
searchTerm.length > 0 && (
<Button variant="secondary" aria-label="Clear input" onClick={handleClear}>
<Icon aria-hidden name="close" />
</Button>
)
}
value={searchTerm}
onChange={handleSearch}
onFocus={handleInputFocus}
ref={inputRef}
/>
{searchTerm.length > 0 && listVisibility && (
<ResultsList searchResults={searchResults} handleClear={handleClear} query={searchTerm} />
)}
Expand Down
3 changes: 3 additions & 0 deletions packages/site-components/src/SearchInput/styles.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export default {
display: ['none', 'none', 'flex', 'flex']
})
]),
input: style({
minWidth: 200
}),
popper: style([
style({
zIndex: POPPER_Z_INDEX,
Expand Down

1 comment on commit 45edb01

@vercel
Copy link

@vercel vercel bot commented on 45edb01 Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

mosaic – ./

mosaic-mosaic-dev-team.vercel.app
mosaic-git-main-mosaic-dev-team.vercel.app

Please sign in to comment.