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(702): static catalog filter at the top of page #778

Merged
merged 1 commit into from
Feb 2, 2024

Conversation

tplevko
Copy link
Contributor

@tplevko tplevko commented Feb 2, 2024

fixes #702

vokoscreenNG-2024-02-02_11-56-08.mp4

Copy link
Member

@lordrip lordrip left a comment

Choose a reason for hiding this comment

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

Awesome 🎉 , thanks @tplevko

Comment on lines 32 to 36
useEffect(() => {
document.getElementById('catalog-list')!.scrollTop = 0;
}, [props.tiles]);

Copy link
Member

Choose a reason for hiding this comment

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

@tplevko This is a great addition 🎉 , I would just suggest if possible, using Ref to get the element instead.

Maybe something like this could work:

  const catalogBodyRef = useRef<HTMLDivElement>(null);

  useEffect(() => {
    catalogBodyRef.current?.scrollTop = 0;
  }, [props.tiles]);

  return (
    <div id="catalog-list" className="catalog-list" ref={catalogBodyRef}>
  ...

This way we're resilient against changes and more important, we delegate the object fetching to react.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great, thanks for the hint! Works with no issue.

I also moved the div, so we would have static displayed element counter at the top.

vokoscreenNG-2024-02-02_12-17-32.mp4

@tplevko tplevko force-pushed the issue_702 branch 4 times, most recently from 10176fe to f33f003 Compare February 2, 2024 12:05
@tplevko tplevko marked this pull request as draft February 2, 2024 12:06
@tplevko tplevko marked this pull request as ready for review February 2, 2024 12:45
@@ -28,25 +30,31 @@ export const BaseCatalog: FunctionComponent<BaseCatalogProps> = (props) => {
[onTileClick, props.tiles],
);

useEffect(() => {
catalogBodyRef.current!.scrollTop = 0;
Copy link
Member

Choose a reason for hiding this comment

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

I think in this case, we can leave it because the div is static, we just need to be aware that this might not be the case always 👀 and we can go 💥

@lordrip lordrip merged commit f854189 into KaotoIO:main Feb 2, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the catalog filter "stick" at the top while scrolling
2 participants