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

Floating Data Catalog Filters Sidebar Follow-up and starting some cleaning and modularizing #930

Merged
merged 6 commits into from
May 6, 2024

Conversation

sandrahoang686
Copy link
Collaborator

@sandrahoang686 sandrahoang686 commented Apr 30, 2024

Related Ticket:

Closes #926

Description of Changes

  • Make filters sidebar height 100% when filters sidebar height (when all expanded) is greater than or equaled to the height of all the cards
  • Calculate filters sidebar height with position:sticky when filters sidebar height (when all expanded) is less than height all of cards
  • Display all filters opened now
  • Move prepareDatasets to own logic file - cleaning
  • Move layout components from Data Catalog component into the wrapper - starting to modularize

Notes & Questions About Changes

DEMO Here:
https://www.loom.com/share/5f88edba7ca4422d9f2636464cebf7b6?sid=62ae3536-4174-4de0-adfe-a19b2e4a5893

Validation / Testing

  • Make sure when the height of the filters sidebar (when expanded) is greater than the height of all the cards, the sidebar doesn't behave sticky
  • Make sure when the height of the filters sidebar (when expanded) is less than the height of all the cards, the sidebar behaves sticky

Copy link

netlify bot commented Apr 30, 2024

Deploy Preview for veda-ui ready!

Name Link
🔨 Latest commit 8f88d13
🔍 Latest deploy log https://app.netlify.com/sites/veda-ui/deploys/6638eeff57e9d50008853bab
😎 Deploy Preview https://deploy-preview-930--veda-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sandrahoang686 sandrahoang686 marked this pull request as ready for review May 1, 2024 18:12
@sandrahoang686 sandrahoang686 changed the title Sticky floating data-catalog filters sidebar Floating Data Catalog Filters Sidebar Follow-up and starting some cleaning and modularizing May 1, 2024
@sandrahoang686
Copy link
Collaborator Author

sandrahoang686 commented May 1, 2024

Demo of how this looks in the GHG instance will be following soon...

@j08lue
Copy link
Contributor

j08lue commented May 1, 2024

Hmm, does not float for me, I think (latest Brave)?
image

@sandrahoang686
Copy link
Collaborator Author

sandrahoang686 commented May 1, 2024

Demo here:
https://www.loom.com/share/5f88edba7ca4422d9f2636464cebf7b6?sid=62ae3536-4174-4de0-adfe-a19b2e4a5893
@j08lue does this ^ help answer your comment. I'm guessing you closed all the filters and was hoping it would still be sticky? I calculate the height of all the filters when they are open and if all the filters height is greater than height of all cards, position sticky doesn't apply. Let me know if this behavior is fine though or if you prefer differently?

@j08lue
Copy link
Contributor

j08lue commented May 1, 2024

Very nice and helpful demo, thanks!

I'm guessing you closed all the filters and was hoping it would still be sticky?

Exactly

I calculate the height of all the filters when they are open and if all the filters height is greater than height of all cards, position sticky doesn't apply.

I imagine this is quite tricky, because you may also need to scroll the side bar in some cases and it does not have its own scroll bar? 🤯

Let me test a bit more on a GHG Center preview (I can set that up shortly) and also see what @faustoperez says, before you make any more changes.

@j08lue
Copy link
Contributor

j08lue commented May 1, 2024

@sandrahoang686 sandrahoang686 requested a review from faustoperez May 2, 2024 13:52
Copy link

@faustoperez faustoperez left a comment

Choose a reason for hiding this comment

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

Ah I see it's more complicated than I thought in the first place, as the height of the element with the accordions and the parent need to be calculated for it to work 🤯 .

To move things forward, I am approving this PR, but let's revisit the behavior after the v2 release.

Ideally, the sidebar would stick at the bottom of the main content when scrolling, it wouldn't scroll up.

Here's a plugin I found in case it helps: https://github.com/blixhavn/sticky-sidebar-v2?tab=readme-ov-file

And a demo: https://blixhavn.github.io/sticky-sidebar-v2/examples/scrollable-element.html

@j08lue
Copy link
Contributor

j08lue commented May 3, 2024

Ideally, the sidebar would stick at the bottom of the main content when scrolling, it wouldn't scroll up.

+1

@sandrahoang686 sandrahoang686 requested a review from dzole0311 May 3, 2024 13:21
@hanbyul-here hanbyul-here force-pushed the update/data-catalog-make-sidebar-floating branch 2 times, most recently from ae04d76 to 42cbe65 Compare May 3, 2024 19:38
@hanbyul-here hanbyul-here force-pushed the update/data-catalog-make-sidebar-floating branch from 42cbe65 to 1e111b2 Compare May 3, 2024 19:43
@hanbyul-here
Copy link
Collaborator

hanbyul-here commented May 3, 2024

I pushed some changes that include

  • "Sticking" to the bottom when content is scrolling - (@faustoperez can you check if this is the behavior you expect to see? )
  • Change sticky behavior depending on the height of the sidebar
  • Change the sticking point depending on the page header status

position: sticky does a lot by default (ex. do not stick when a sticky element is longer than the contents) I think what this PR was missing was to give an actual height value to the sticky element. I got rid of the logic of comparing the heights of 'area' and 'sidebar' since they are not needed anymore. I did not clean up further than data-catalog/filters-control, data-catalog/index , so a further clean-up might be needed.

const [count, setCount] = useState<number>(0);
const [selected, setSelected] = useState<OptionItem[]>([]);
const targetRef = React.useRef<HTMLDivElement>(null);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there any need to introduce the pattern of using React.useRef? I am not sure we can set it up as a lint rule, but all other parts of the code explicitly import {useRef}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not a pattern, can just explicitly import or use like this

setAllSelectedFilters([]);
}, [setAllSelectedFilters]);

React.useEffect(() => {
useEffect(() => {
if (clearedTagItem && (allSelectedFilters.length == prevSelectedFilters.length-1)) {
onAction(Actions.TAXONOMY_MULTISELECT, { key: clearedTagItem.taxonomy, value: clearedTagItem.id});
setClearedTagItem(undefined);
}
}, [allSelectedFilters, clearedTagItem]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed warnings about useEffect has missing dependencies throughout this component. Do you mind putting comments on why those dependencies are excluded? It would help me navigate the code better.

Copy link
Collaborator Author

@sandrahoang686 sandrahoang686 May 6, 2024

Choose a reason for hiding this comment

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

Sure. We have missing dependencies sprinkled throughout the existing codebase already. We can start making notes going forward why some arn't included and as a team create standardization around this in-code documentation

@j08lue
Copy link
Contributor

j08lue commented May 6, 2024

Awesome, the scrolling experience is great now - the filters are visible until the very end of the dataset list and the behavior takes into account the actual height of the side bar. This way, users will always be able to see the filters.

One deviation from the design is that the pills that indicate the active filters and give a shortcut to removing them are added in the right column, above the dataset list:

image

Instead of between search bar and filters:

image

That means that the shortcut to removing individual filters disappears from view quite quickly as the user scrolls down the filtered list. Was this a change you discussed, @faustoperez and @sandrahoang686?

We could keep that refinement to yet another PR, though, and ship this increment already. 👌

@sandrahoang686
Copy link
Collaborator Author

@j08lue yes that was a change Fausto and I discussed this during our checkin and in the original PR to have the tags above the dataset list instead of above the filters. Decision change documented here

@sandrahoang686 sandrahoang686 merged commit db802a1 into main May 6, 2024
8 checks passed
@sandrahoang686 sandrahoang686 deleted the update/data-catalog-make-sidebar-floating branch May 6, 2024 18:58
Copy link
Contributor

@j08lue j08lue left a comment

Choose a reason for hiding this comment

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

As noted in #930 (comment), the implementation works very nicely!

The small difference from the designs in terms of placement of the filter removal pills is ok for now for me.

hanbyul-here added a commit that referenced this pull request May 6, 2024
### Features

* Floating Data Catalog Filters Sidebar Follow-up and starting some
cleaning and modularizing in
#930
* Make geometries non-movable in the Exploration feature in
#936
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.

[Data Catalog] Follow up on missing details
4 participants