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

feat(table): add autoFocus as new props #101

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.1.32

- Add autoFocus props to the table component

## 2.1.31

- Remove margintop from main header to avoid overriding
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@catena-x/portal-shared-components",
"version": "2.1.31",
"version": "2.1.32",
"description": "Catena-X Portal Shared Components",
"author": "Catena-X Contributors",
"license": "Apache-2.0",
Expand Down
4 changes: 1 addition & 3 deletions src/components/basic/Table/components/Helper/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ export interface PageDataRows {
}

export const hasMorePages = (data: PageDataProps) => {
return (
data?.meta && data.meta.page < data.meta.totalPages - 1
)
return data?.meta && data.meta.page < data.meta.totalPages - 1
}

export const getMaxRows = (data: PageDataRows) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface SearchAndFilterButtonToolbarProps extends ToolbarProps {
defaultFilter?: string
onFilter?: (selectedFilter: SelectedFilter) => void
descriptionText?: string
autoFocus?: boolean
}

export const SearchAndFilterButtonToolbar = ({
Expand All @@ -49,6 +50,7 @@ export const SearchAndFilterButtonToolbar = ({
filterViews,
defaultFilter = '',
descriptionText,
autoFocus,
}: SearchAndFilterButtonToolbarProps) => {
const [searchInputText, setSearchInputText] = useState<string>(
searchExpr ?? (searchInputData != null ? searchInputData.text : '')
Expand Down Expand Up @@ -115,7 +117,7 @@ export const SearchAndFilterButtonToolbar = ({
<Box sx={styles}>
<Box sx={{ display: 'flex', alignItems: 'center', height: '50px' }}>
<SearchInput
autoFocus
autoFocus={autoFocus}
endAdornment={endAdornment}
value={searchInputText}
onChange={onSearchChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface UltimateToolbarProps extends ToolbarProps {
selectedFilter?: SelectedFilter
searchDebounce?: number
searchExpr?: string
autoFocus?: boolean
}

export const UltimateToolbar = ({
Expand All @@ -44,6 +45,7 @@ export const UltimateToolbar = ({
searchInputData,
onClearSearch,
searchDebounce = 500,
autoFocus,
}: UltimateToolbarProps) => {
const { spacing } = useTheme()
const [searchInput, setSearchInput] = useState<string>(
Expand Down Expand Up @@ -114,7 +116,7 @@ export const UltimateToolbar = ({
{onSearch != null && (
<Box sx={{ display: 'flex', alignItems: 'center', height: '50px' }}>
<SearchInput
autoFocus
autoFocus={autoFocus}
endAdornment={endAdornment}
value={searchInput}
onChange={onSearchChange}
Expand Down
4 changes: 3 additions & 1 deletion src/components/basic/Table/components/Toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface ToolbarProps {
onOpenFilterSection?: (value: boolean) => void
selectedFilter?: SelectedFilter
onClearSearch?: () => void
autoFocus?: boolean
}

const getIconColor = (openFilter: boolean) => {
Expand All @@ -92,6 +93,7 @@ export const Toolbar = ({
onOpenFilterSection,
selectedFilter,
onClearSearch,
autoFocus,
}: ToolbarProps) => {
const { spacing } = useTheme()
const isSearchText = searchExpr && searchExpr !== ''
Expand Down Expand Up @@ -213,7 +215,7 @@ export const Toolbar = ({
<Box sx={{ display: 'flex', justifyContent: 'flex-end' }}>
{openSearch ? (
<SearchInput
autoFocus
autoFocus={autoFocus}
endAdornment={getEndAdornment()}
value={searchInput}
onChange={onSearchInputChange}
Expand Down
3 changes: 3 additions & 0 deletions src/components/basic/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface TableProps extends DataGridProps {
status: number
}
reload?: () => void
autoFocus?: boolean
}

export const Table = ({
Expand Down Expand Up @@ -103,6 +104,7 @@ export const Table = ({
alignCell = 'center',
error,
reload,
autoFocus = true,
...props
}: TableProps) => {
const toolbarProps = {
Expand All @@ -122,6 +124,7 @@ export const Table = ({
descriptionText,
defaultFilter,
filterViews,
autoFocus,
}

// TODO: this method contains application specific row attributes and must therefore
Expand Down
Loading