Skip to content

Commit 5704894

Browse files
committed
feat(searchform): add result in searchform's placeholder
Replace heading with the result domain directly in the search form's placeholder
1 parent 6bd5250 commit 5704894

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/components/SearchForm.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const SearchForm = () => {
1313
const { historyPush } = useHistoryModal();
1414
const [isValid, setIsValid] = useState<boolean>(true);
1515

16+
const domain = searchParams.get('domain');
17+
1618
useEffect(() => {
1719
window.addEventListener('keyup', handleKeyUp);
1820

@@ -34,12 +36,13 @@ const SearchForm = () => {
3436

3537
const transformedDomain = domainPipe(extractDomain)(searchQuery);
3638
const isValid = isDomainValid(transformedDomain);
37-
if (searchParams.get('domain') === transformedDomain || !isValid) {
39+
if (domain === transformedDomain || !isValid) {
3840
return;
3941
}
4042

4143
historyPush(transformedDomain);
4244
setSearchParams({ domain: transformedDomain });
45+
setSearchQuery('');
4346
navigate(`/results?domain=${encodeURIComponent(transformedDomain)}`);
4447
setTimeout(() => window.scroll(0, 0), 50);
4548
};
@@ -61,7 +64,7 @@ const SearchForm = () => {
6164
<input
6265
type="text"
6366
className="grow placeholder:text-xs "
64-
placeholder="Type a valid domain..."
67+
placeholder={domain ?? 'Type a valid domain...'}
6568
autoFocus
6669
value={searchQuery}
6770
onChange={event => setSearchQuery(event.target.value.toLowerCase())}

src/views/Results.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ const Results = () => {
104104
<>
105105
<Meta loading={isLoading} />
106106
<Navbar />
107-
<ViewContainer className="p-4 mt-10">
108-
<H1 className="my-5 text-2xl">
109-
Looking up {searchParams.get('domain')}
110-
</H1>
107+
<ViewContainer className="p-5 mt-16">
111108
<Markers
112109
isWhoisLoading={isWhoIsLoading}
113110
isDnsLoading={isDnsLoading}

0 commit comments

Comments
 (0)