Skip to content

Commit

Permalink
Fix a few view select issues (#8670)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Eilers authored Aug 21, 2023
1 parent 022d1d0 commit a17ed80
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
23 changes: 16 additions & 7 deletions datahub-web-react/src/app/entity/view/select/ViewSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useRef, useState } from 'react';
import React, { CSSProperties, useEffect, useRef, useState } from 'react';
import { useHistory } from 'react-router';
import { Select } from 'antd';
import styled from 'styled-components';
Expand Down Expand Up @@ -55,11 +55,21 @@ const ViewSelectContainer = styled.div`
.ant-select-selection-item {
font-weight: 700;
font-size: 14px;
text-align: left;
}
}
}
`;

const SelectStyled = styled(Select)`
min-width: 90px;
max-width: 200px;
`;

type Props = {
dropdownStyle?: CSSProperties;
};

/**
* The View Select component allows you to select a View to apply to query on the current page. For example,
* search, recommendations, and browse.
Expand All @@ -69,7 +79,7 @@ const ViewSelectContainer = styled.div`
*
* In the event that a user refreshes their browser, the state of the view should be saved as well.
*/
export const ViewSelect = () => {
export const ViewSelect = ({ dropdownStyle = {} }: Props) => {
const history = useHistory();
const userContext = useUserContext();
const [isOpen, setIsOpen] = useState(false);
Expand Down Expand Up @@ -188,12 +198,11 @@ export const ViewSelect = () => {

return (
<ViewSelectContainer>
<Select
<SelectStyled
data-testid="view-select"
style={{ minWidth: '120px', maxWidth: '200px' }}
onChange={() => (selectRef?.current as any)?.blur()}
value={(foundSelectedUrn && selectedUrn) || undefined}
placeholder="All Entities"
placeholder="View all"
onSelect={onSelectView}
onClear={onClear}
ref={selectRef}
Expand All @@ -202,8 +211,8 @@ export const ViewSelect = () => {
dropdownMatchSelectWidth={false}
suffixIcon={<TriangleIcon isOpen={isOpen} />}
dropdownStyle={{
position: 'fixed',
paddingBottom: 0,
...dropdownStyle,
}}
onDropdownVisibleChange={handleDropdownVisibleChange}
dropdownRender={(menu) => (
Expand Down Expand Up @@ -237,7 +246,7 @@ export const ViewSelect = () => {
onClickEditView,
onClickPreviewView,
})}
</Select>
</SelectStyled>
{viewBuilderDisplayState.visible && (
<ViewBuilder
urn={viewBuilderDisplayState.view?.urn || undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const ViewSelectHeader = ({ onClickClear }: Props) => {
ref={clearButtonRef}
onClick={onHandleClickClear}
>
All Entities
View all
</AllEntitiesButton>
</ButtonContainer>
);
Expand Down
10 changes: 9 additions & 1 deletion datahub-web-react/src/app/search/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,15 @@ export const SearchBar = ({
onKeyUp={handleStopPropagation}
onKeyDown={handleStopPropagation}
>
<ViewSelect />
<ViewSelect
dropdownStyle={
fixAutoComplete
? {
position: 'fixed',
}
: {}
}
/>
</ViewSelectContainer>
)}
<SearchIcon
Expand Down

0 comments on commit a17ed80

Please sign in to comment.