Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Navigation Target Styles #109

Merged
merged 11 commits into from
Mar 29, 2023
Merged

Navigation Target Styles #109

merged 11 commits into from
Mar 29, 2023

Conversation

arniebradfo
Copy link
Collaborator

@arniebradfo arniebradfo commented Mar 27, 2023

Description

When navigating to a row of a scrolling list (like a command), we want to apply some kind of visual indicator of the target. This is traditionally styled with the :target pseudo selector when navigating to an internal anchor link. We are implementing it differently but the concept is the same

  • Added UtilityStyle.scrollTarget
  • implemented UtilityStyle.scrollTarget on:
    • RawLogs lines
    • Command InfoRows - scrollTarget is added and then removed by the scrollToCommand method
    • InfoRows generally via the scrollTarget prop

TODOs

  • Implement this on Comments (Later PR)
    • Clicking a comment from the search dialog won't navigate to it. It should, and it should apply the target style
  • Maintain scroll position between navigation including back button (Later PR)

Testing

  • After the todos

Screenshots

Screen Shot 2023-03-27 at 9 27 48 AM
Screen Shot 2023-03-27 at 9 27 51 AM
Screen Shot 2023-03-27 at 10 43 09 AM

@arniebradfo arniebradfo marked this pull request as ready for review March 28, 2023 17:48
Comment on lines +34 to 42
scrollTargetIndex: -1,
scrollToCommand(commandId: string, commandIds: string[], behavior: ScrollBehavior = 'smooth') {
const commandIndex = commandIds.findIndex((id) => commandId === id);
this.scrollTargetIndex = commandIndex;
if (commandIndex > -1) {
listRef?.current?.scrollToIndex({ index: commandIndex, align: 'start', behavior });
setTimeout(() => (this.scrollTargetIndex = -1), UtilityStyles.SCROLL_TARGET_DURATION + 500);
}
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Setting and then removing the scrollTargetIndex based on the scrollToCommand method seems like the best solution to style the item only when scrolling to it.

@sang2925 sang2925 merged commit cce963f into develop Mar 29, 2023
@sang2925 sang2925 deleted the restore-router-target-style branch March 29, 2023 19:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants