-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
useScrollStates hook created replacing direct access to scrollTopState & scrollLeftState #4938
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9ed7f4e
Added isAuditLogged column to object-metadata-entity
Jeetch8 aed44d3
update - added isAuditLogged to interface and EntityEventsToDbListener
Jeetch8 bd493c1
Merge branch 'twentyhq:main' into main
Jeetch8 9b4f777
useScrollStates added replacing scrollLeftState & scrollTopState
Jeetch8 a871c26
Merge branch 'main' into useScrollStates
Jeetch8 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/twenty-front/src/modules/ui/utilities/scroll/hooks/useScrollSates.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useAvailableScopeIdOrThrow } from "@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId"; | ||
import { scrollLeftComponentState } from "@/ui/utilities/scroll/states/scrollLeftComponentState"; | ||
import { scrollTopComponentState } from "@/ui/utilities/scroll/states/scrollTopComponentState"; | ||
import { extractComponentState } from "@/ui/utilities/state/component-state/utils/extractComponentState" | ||
import { ViewScopeInternalContext } from "@/views/scopes/scope-internal-context/ViewScopeInternalContext"; | ||
|
||
export const useScrollStates = (scrollWrapperId?:string) => { | ||
const componentId = useAvailableScopeIdOrThrow( | ||
ViewScopeInternalContext, | ||
scrollWrapperId, | ||
); | ||
|
||
return{ | ||
scrollLeftState: extractComponentState( | ||
scrollLeftComponentState, | ||
componentId | ||
), | ||
scrollTopState: extractComponentState( | ||
scrollTopComponentState, | ||
componentId | ||
) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/twenty-front/src/modules/ui/utilities/scroll/states/scrollLeftComponentState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState'; | ||
|
||
export const scrollLeftComponentState = createComponentState<number>({ | ||
key: 'scroll/scrollLeftState', | ||
defaultValue: 0, | ||
}); |
6 changes: 0 additions & 6 deletions
6
packages/twenty-front/src/modules/ui/utilities/scroll/states/scrollLeftState.ts
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
packages/twenty-front/src/modules/ui/utilities/scroll/states/scrollTopComponentState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState'; | ||
|
||
export const scrollTopComponentState = createComponentState<number>({ | ||
key: 'scroll/scrollTopState', | ||
defaultValue: 0, | ||
}); |
6 changes: 0 additions & 6 deletions
6
packages/twenty-front/src/modules/ui/utilities/scroll/states/scrollTopState.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in the filename that should be useScrollStates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you move this hook into a internal subfolder within hooks. internal hooks cannot be used outside of their component (here Scroll / ScrollWrapper).
This allows us to narrow down the public API of a component to enforce interface (easy maintenance).
We will need to create another useScrollTopValue(scrollWraperId) and useScrollLeftValue(scrollWraperId) hooks. These hooks will only expose what functions we want it to expose.
Here we would for example only want to expose the getter: useRecoilValue(scrollLeftState) (scrollLeftState being imported from useScrollStates)
Then from ColumnHead, Recordtable, RecordTableHeaderCell you can use useScrollTopValue and useScrollLeftValue