mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-03 14:16:28 +00:00
Fix a few view select issues (#8670)
This commit is contained in:
parent
022d1d0784
commit
a17ed80cf7
@ -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}
|
||||
|
||||
@ -42,7 +42,7 @@ export const ViewSelectHeader = ({ onClickClear }: Props) => {
|
||||
ref={clearButtonRef}
|
||||
onClick={onHandleClickClear}
|
||||
>
|
||||
All Entities
|
||||
View all
|
||||
</AllEntitiesButton>
|
||||
</ButtonContainer>
|
||||
);
|
||||
|
||||
@ -377,7 +377,15 @@ export const SearchBar = ({
|
||||
onKeyUp={handleStopPropagation}
|
||||
onKeyDown={handleStopPropagation}
|
||||
>
|
||||
<ViewSelect />
|
||||
<ViewSelect
|
||||
dropdownStyle={
|
||||
fixAutoComplete
|
||||
? {
|
||||
position: 'fixed',
|
||||
}
|
||||
: {}
|
||||
}
|
||||
/>
|
||||
</ViewSelectContainer>
|
||||
)}
|
||||
<SearchIcon
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user