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 missing scrollbar in table component #382

Merged
merged 2 commits into from
Aug 5, 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
3 changes: 3 additions & 0 deletions core/src/db/entity/user/preferences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ pub struct UserPreferences {
pub enable_compact_display: bool,
#[serde(default = "default_true")]
pub enable_double_sidebar: bool,
// TODO: refactor usage of enable_hide_scrollbar to function as local scrollbar hiding
#[serde(default)]
pub enable_hide_scrollbar: bool,
// TODO: support hiding global vs local scrollbars (e.g. tables)
// pub enable_hide_global_scrollbar: bool,
#[serde(default)]
pub enable_replace_primary_sidebar: bool,
#[serde(default = "default_true")]
Expand Down
14 changes: 12 additions & 2 deletions packages/browser/src/components/table/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Heading, NativeSelect, Text } from '@stump/components'
import { cn, Heading, NativeSelect, Text } from '@stump/components'
import {
Column,
ColumnDef,
Expand All @@ -17,6 +17,8 @@ import clsx from 'clsx'
import { ArrowDown, ArrowUp } from 'lucide-react'
import { CSSProperties, useMemo, useRef, useState } from 'react'

import { usePreferences } from '@/hooks/usePreferences'

import TablePagination from './Pagination'
import TableFilterInput from './TableFilterInput'
import TableFilterSelect from './TableFilterSelect'
Expand Down Expand Up @@ -52,6 +54,10 @@ export default function Table<T, V>({
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([])
const [globalFilter, setGlobalFilter] = useState('')

const {
preferences: { enable_hide_scrollbar },
} = usePreferences()

const table = useReactTable({
onSortingChange: setSorting,
...options,
Expand Down Expand Up @@ -116,7 +122,11 @@ export default function Table<T, V>({

return (
<>
<div className="divide block max-w-full overflow-y-hidden overflow-x-scroll p-3 scrollbar-hide">
<div
className={cn('divide block max-w-full overflow-y-hidden overflow-x-scroll p-3', {
'scrollbar-hide': enable_hide_scrollbar,
})}
>
<table className={clsx('divide-y', { 'w-full': props.fullWidth })}>
<thead className="border-b border-edge text-left">
{table.getHeaderGroups().map((headerGroup) => (
Expand Down
Loading