Fix a few view select issues (#8670)

This commit is contained in:
Joshua Eilers 2023-08-21 09:47:05 -07:00 committed by GitHub
parent 022d1d0784
commit a17ed80cf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 9 deletions

View File

@ -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';
@ -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.
@ -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);
@ -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}
@ -202,8 +211,8 @@ export const ViewSelect = () => {
dropdownMatchSelectWidth={false}
suffixIcon={<TriangleIcon isOpen={isOpen} />}
dropdownStyle={{
position: 'fixed',
paddingBottom: 0,
...dropdownStyle,
}}
onDropdownVisibleChange={handleDropdownVisibleChange}
dropdownRender={(menu) => (
@ -237,7 +246,7 @@ export const ViewSelect = () => {
onClickEditView,
onClickPreviewView,
})}
</Select>
</SelectStyled>
{viewBuilderDisplayState.visible && (
<ViewBuilder
urn={viewBuilderDisplayState.view?.urn || undefined}

View File

@ -42,7 +42,7 @@ export const ViewSelectHeader = ({ onClickClear }: Props) => {
ref={clearButtonRef}
onClick={onHandleClickClear}
>
All Entities
View all
</AllEntitiesButton>
</ButtonContainer>
);

View File

@ -377,7 +377,15 @@ export const SearchBar = ({
onKeyUp={handleStopPropagation}
onKeyDown={handleStopPropagation}
>
<ViewSelect />
<ViewSelect
dropdownStyle={
fixAutoComplete
? {
position: 'fixed',
}
: {}
}
/>
</ViewSelectContainer>
)}
<SearchIcon