Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keep search text #684

Merged
merged 15 commits into from
Nov 22, 2022
Merged

fix: keep search text #684

merged 15 commits into from
Nov 22, 2022

Conversation

qiweiii
Copy link
Contributor

@qiweiii qiweiii commented Oct 26, 2022

resolves Magickbase/godwoken_explorer#1107

  1. keep search texts after page redirects

@auto-add-label auto-add-label bot added the bug Something isn't working label Oct 26, 2022
@vercel
Copy link

vercel bot commented Oct 26, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
godwoken-explorer-ui ✅ Ready (Inspect) Visit Preview Nov 22, 2022 at 3:55AM (UTC)

@qiweiii
Copy link
Contributor Author

qiweiii commented Oct 26, 2022

On first render, in 404 page, it cannot get search text from url, next.js has a related open issue: #35990.

Update:
But Search component is actually in _app, another related discussion: vercel/next.js#11484

Update:
Solved using:

const queryKey = 'search'
const queryValue = query[queryKey] || asPath.match(new RegExp(`[&?]${queryKey}=(.*)(&|$)`))

@@ -34,12 +34,6 @@ export const handleSearchKeyPress = async (e: React.KeyboardEvent<HTMLInputEleme
return
}

if (Number.isNaN(+search)) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not check if the search is a hash or block number before the request?

Copy link
Member

Choose a reason for hiding this comment

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

I've got it

fix redirect to tokens list logic, if token name is matched, go to token details page directly

But the solution is improper because there could be many tokens having a same token name while the API only returns the first one, which is misleading

Copy link
Member

Choose a reason for hiding this comment

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

@zmcNotafraid we'd better remove the function of searching by token name, or return a list instead of the first record

Copy link
Member

Choose a reason for hiding this comment

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

The API will be updated along with Magickbase/godwoken_explorer#1159 and a new page of matched token list will be added in the future.

Now just let's just recover the checking of token name before sending the request @qiweiii

@FrederLu
Copy link
Contributor

image

image

Jumping to the results page by searching, the delete button is not displayed in the search box. A delete button is displayed when entering information in the search box.

@codecov-commenter
Copy link

codecov-commenter commented Nov 12, 2022

Codecov Report

Merging #684 (d2b9686) into develop (8b1988f) will increase coverage by 0.10%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #684      +/-   ##
===========================================
+ Coverage    56.81%   56.91%   +0.10%     
===========================================
  Files           11       11              
  Lines          704      701       -3     
  Branches       423      423              
===========================================
- Hits           400      399       -1     
+ Misses         278      276       -2     
  Partials        26       26              
Impacted Files Coverage Δ
pages/blocks.tsx 4.16% <0.00%> (-3.25%) ⬇️

@qiweiii
Copy link
Contributor Author

qiweiii commented Nov 17, 2022

@FrederLu fixed, please check

components/Search.tsx Outdated Show resolved Hide resolved
components/Search.tsx Outdated Show resolved Hide resolved
@qiweiii
Copy link
Contributor Author

qiweiii commented Nov 21, 2022

@FrederLu fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search text should be retained after page jumping
4 participants