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: Database selector overflow #17369

Merged
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
16 changes: 14 additions & 2 deletions superset-frontend/src/components/DatabaseSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const DatabaseSelectorWrapper = styled.div`
}

.select {
width: calc(100% - 30px - ${theme.gridUnit}px);
flex: 1;
}

Expand All @@ -55,6 +56,15 @@ const LabelStyle = styled.div`
flex-direction: row;
align-items: center;
margin-left: ${({ theme }) => theme.gridUnit - 2}px;

.backend {
overflow: visible;
}

.name {
overflow: hidden;
text-overflow: ellipsis;
}
`;

type DatabaseValue = {
Expand Down Expand Up @@ -97,8 +107,10 @@ const SelectLabel = ({
databaseName: string;
}) => (
<LabelStyle>
<Label>{backend}</Label>
{databaseName}
<Label className="backend">{backend}</Label>
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better if we created separate styled components instead of adding classes to the container?

Copy link
Member Author

Choose a reason for hiding this comment

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

Every styled component generates a class underneath. I think this pattern is better for highly correlated components like this example, where all subcomponents are part of an atomic label. Breaking styles into multiple components for atomic units seems worse.

<span className="name" title={databaseName}>
{databaseName}
</span>
</LabelStyle>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ describe('TimezoneSelector', () => {
});
expect(select).toBeInTheDocument();
userEvent.click(select);
const selection = await screen.findByTitle(
'GMT -06:00 (Mountain Daylight Time)',
);
const selection = await screen.findByTitle('GMT -06:00 (America/Belize)');
Copy link
Member

Choose a reason for hiding this comment

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

we should coverage "offsetsToName" in src/components/TimezoneSelector/index.tsx. I have a seprate PR do this.

expect(selection).toBeInTheDocument();
userEvent.click(selection);
expect(selection).toBeVisible();
Expand Down