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(pro:search): remove name input min-width #1551

Merged
merged 1 commit into from
May 17, 2023
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
3 changes: 2 additions & 1 deletion packages/pro/search/src/components/NameSelectOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ export default defineComponent({
panelKeyDown = keydown
}
const handleKeyDown = (evt: KeyboardEvent) => {
if (!selectedFieldKey.value && evt.key === 'Enter') {
if (!filteredDataSource.value.length && evt.key === 'Enter') {
callEmit(proSearchProps.onItemCreate, {
name: undefined,
nameInput: props.searchValue,
})
props.onChange?.(undefined)
return false
}

if (!overlayOpened.value || !panelKeyDown) {
Expand Down
4 changes: 4 additions & 0 deletions packages/pro/search/src/components/segment/Segment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ export default defineComponent({
setOverlayOpened(false)
handleSegmentCancel(props.segment.name)
}
const handleMouseDown = (evt: MouseEvent) => {
evt.stopImmediatePropagation()
}

const { handleInput, handleFocus, handleKeyDown, setPanelOnKeyDown } = useInputEvents(
props,
Expand All @@ -166,6 +169,7 @@ export default defineComponent({
onInput={handleInput}
onFocus={handleFocus}
onKeydown={handleKeyDown}
onMousedown={handleMouseDown}
onWidthChange={triggerOverlayUpdate}
></SegmentInput>
)
Expand Down
8 changes: 5 additions & 3 deletions packages/pro/search/src/components/segment/SegmentInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

import { computed, defineComponent, inject, normalizeClass, onMounted, ref, watch } from 'vue'
import { type CSSProperties, computed, defineComponent, inject, normalizeClass, onMounted, ref, watch } from 'vue'

import { callEmit, convertCssPixel, useState } from '@idux/cdk/utils'

Expand Down Expand Up @@ -63,19 +63,21 @@ export default defineComponent({

return () => {
const prefixCls = `${mergedPrefixCls.value}-segment-input`
const { class: className, style, ...rest } = attrs

return (
<span class={classes.value}>
<span class={normalizeClass([classes.value, className])}>
<input
ref={segmentInputRef}
class={`${prefixCls}-inner`}
style={style as CSSProperties}
value={props.value ?? ''}
disabled={props.disabled}
placeholder={props.placeholder}
onInput={handleInput}
onCompositionstart={handleCompositionStart}
onCompositionend={handleCompositionEnd}
{...attrs}
{...rest}
></input>
<MeasureElement onWidthChange={setInputWidth}>{props.value || props.placeholder || ''}</MeasureElement>
</span>
Expand Down
97 changes: 0 additions & 97 deletions packages/pro/search/src/segments/CreateNameSegment.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/pro/search/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@
}
}
&-temp-segment-input {
min-width: 100px;
margin-left: 8px;
}
&-name-segment-overlay {
Expand Down