This is an automated email from the ASF dual-hosted git repository. msyavuz pushed a commit to branch msyavuz/fix/select-conflicts-bug in repository https://gitbox.apache.org/repos/asf/superset.git
commit 2f0515eb5f74225e6b9bc839821a651fefa262ff Author: Mehmet Salih Yavuz <[email protected]> AuthorDate: Thu Apr 17 21:06:34 2025 +0300 fix: post merge fixes --- .../src/components/Select/AsyncSelect.tsx | 2 - .../src/components/Select/CustomTag.tsx | 52 ---------------------- superset-frontend/src/components/Select/Select.tsx | 23 +++++----- superset-frontend/src/components/Select/index.tsx | 1 - superset-frontend/src/components/Select/styles.tsx | 7 --- superset-frontend/src/components/Select/types.ts | 7 --- .../components/Select/SelectFilterPlugin.tsx | 4 +- 7 files changed, 15 insertions(+), 81 deletions(-) diff --git a/superset-frontend/src/components/Select/AsyncSelect.tsx b/superset-frontend/src/components/Select/AsyncSelect.tsx index 2a7ec1b219..d31d69df0b 100644 --- a/superset-frontend/src/components/Select/AsyncSelect.tsx +++ b/superset-frontend/src/components/Select/AsyncSelect.tsx @@ -85,7 +85,6 @@ import { TOKEN_SEPARATORS, DEFAULT_SORT_COMPARATOR, } from './constants'; -import { customTagRender } from './CustomTag'; const Error = ({ error }: { error: string }) => ( <StyledError> @@ -635,7 +634,6 @@ const AsyncSelect = forwardRef( ) } oneLine={oneLine} - tagRender={customTagRender} {...props} ref={ref} /> diff --git a/superset-frontend/src/components/Select/CustomTag.tsx b/superset-frontend/src/components/Select/CustomTag.tsx deleted file mode 100644 index 750774fd11..0000000000 --- a/superset-frontend/src/components/Select/CustomTag.tsx +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import { MouseEvent } from 'react'; -import { Tag } from '../Tag'; -import { CustomTagProps } from './types'; - -/** - * Custom tag renderer - */ -export const customTagRender = (props: CustomTagProps) => { - const { label } = props; - - const onPreventMouseDown = (event: MouseEvent<HTMLElement>) => { - // if close icon is clicked, stop propagation to avoid opening the dropdown - const target = event.target as HTMLElement; - if ( - target.tagName === 'svg' || - target.tagName === 'path' || - (target.tagName === 'span' && - target.className.includes('antd5-tag-close-icon')) - ) { - event.stopPropagation(); - } - }; - - return ( - <Tag - onMouseDown={onPreventMouseDown} - name={label} - className="antd5-select-selection-item" - {...(props as object)} - > - {label} - </Tag> - ); -}; diff --git a/superset-frontend/src/components/Select/Select.tsx b/superset-frontend/src/components/Select/Select.tsx index 8f6af815bd..1057c92929 100644 --- a/superset-frontend/src/components/Select/Select.tsx +++ b/superset-frontend/src/components/Select/Select.tsx @@ -71,7 +71,6 @@ import { TOKEN_SEPARATORS, VIRTUAL_THRESHOLD, } from './constants'; -import { customTagRender } from './CustomTag'; import { Space } from '../Space'; import { Button } from '../Button'; @@ -358,12 +357,17 @@ const Select = forwardRef( let updatedOptions = selectOptions; if (allowNewOptions) { - const newOption = searchValue && - !hasOption(searchValue, fullSelectOptions, true) && { - label: searchValue, - value: searchValue, - isNewOption: true, - }; + const optionsWithoutTemporary = ensureIsArray(fullSelectOptions).filter( + opt => !opt.isNewOption, + ); + const shouldCreateNewOption = + searchValue && !hasOption(searchValue, optionsWithoutTemporary, true); + + const newOption = shouldCreateNewOption && { + label: searchValue, + value: searchValue, + isNewOption: true, + }; const cleanSelectOptions = ensureIsArray(fullSelectOptions).filter( opt => !opt.isNewOption || hasOption(opt.value, selectValue), ); @@ -457,7 +461,7 @@ const Select = forwardRef( () => ( <StyledBulkActionsContainer size={0}> <Button - type="link" + buttonStyle="link" buttonSize="xsmall" disabled={bulkSelectCounts.selectable === 0} onMouseDown={e => { @@ -469,7 +473,7 @@ const Select = forwardRef( {`${t('Select all')} (${bulkSelectCounts.selectable})`} </Button> <Button - type="link" + buttonStyle="link" buttonSize="xsmall" disabled={bulkSelectCounts.deselectable === 0} onMouseDown={e => { @@ -729,7 +733,6 @@ const Select = forwardRef( options={visibleOptions} optionRender={option => <Space>{option.label || option.value}</Space>} oneLine={oneLine} - tagRender={customTagRender} css={props.css} {...props} showSearch={shouldShowSearch} diff --git a/superset-frontend/src/components/Select/index.tsx b/superset-frontend/src/components/Select/index.tsx index 97edc499a2..004c22e7f2 100644 --- a/superset-frontend/src/components/Select/index.tsx +++ b/superset-frontend/src/components/Select/index.tsx @@ -22,5 +22,4 @@ import AsyncSelect from './AsyncSelect'; export { Select, AsyncSelect }; export * from './types'; export * from './styles'; -export * from './CustomTag'; export * from './constants'; diff --git a/superset-frontend/src/components/Select/styles.tsx b/superset-frontend/src/components/Select/styles.tsx index 9c63aaf42f..173c006222 100644 --- a/superset-frontend/src/components/Select/styles.tsx +++ b/superset-frontend/src/components/Select/styles.tsx @@ -138,12 +138,5 @@ export const StyledBulkActionsContainer = styled(Space)` display: flex; justify-content: center; border-top: 1px solid ${theme.colors.grayscale.light3}; - .superset-button { - color: ${theme.colorPrimaryText}; - font-weight: ${theme.fontWeightNormal}; - } - .superset-button:disabled { - background-color: transparent; - } `} `; diff --git a/superset-frontend/src/components/Select/types.ts b/superset-frontend/src/components/Select/types.ts index a48e5aedea..9676e2f046 100644 --- a/superset-frontend/src/components/Select/types.ts +++ b/superset-frontend/src/components/Select/types.ts @@ -23,7 +23,6 @@ import { LabeledValue as AntdLabeledValue, RefSelectProps, } from 'antd-v5/es/select'; -import { TagProps } from 'antd-v5/es/tag'; import { Interpolation, Theme } from '@emotion/react'; export type RawValue = string | number; @@ -231,9 +230,3 @@ export interface AsyncSelectProps extends BaseSelectProps { */ onError?: (error: string) => void; } - -export type CustomTagProps = HTMLSpanElement & - TagProps & { - label: ReactNode; - value: string; - }; diff --git a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx index 89b76658d2..e7189b342a 100644 --- a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx +++ b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx @@ -91,8 +91,8 @@ const StyledSpace = styled(Space)<{ $inverseSelection: boolean }>` flex-shrink: 0; } - &.ant-space { - .ant-space-item { + &.antd5-space { + .antd5-space-item { width: ${({ $inverseSelection }) => !$inverseSelection ? '100%' : 'auto'}; }
