Skip to content

Commit

Permalink
chore: This would do it
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Carvalho committed Sep 13, 2023
1 parent 03e59f2 commit 4f46fb7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
4 changes: 2 additions & 2 deletions pages/autosuggest/simple.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { useState } from 'react';
import Autosuggest from '~components/autosuggest';

const empty = <span>Nothing found</span>;
const empty = undefined;
const options = [
{ value: 'Option 0', tags: ['tag1', 'tag2'], filteringTags: ['bla', 'opt'], description: 'description1' },
{ value: 'Option 1', labelTag: 'This is a label tag' },
Expand All @@ -14,7 +14,7 @@ const enteredTextLabel = (value: string) => `Use: ${value}`;
export default function AutosuggestPage() {
const [value, setValue] = useState('');
const [readOnly, setReadOnly] = useState(false);
const [hasOptions, setHasOptions] = useState(true);
const [hasOptions, setHasOptions] = useState(false);

return (
<div style={{ padding: 10 }}>
Expand Down
3 changes: 2 additions & 1 deletion src/autosuggest/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const InternalAutosuggest = React.forwardRef((props: InternalAutosuggestProps, r
onRecoveryClick: handleRecoveryClick,
filteringResultsText: filteredText,
});

console.log({ isEmpty });
return (
<AutosuggestInput
{...restProps}
Expand All @@ -202,6 +202,7 @@ const InternalAutosuggest = React.forwardRef((props: InternalAutosuggestProps, r
ariaLabel={ariaLabel}
ariaRequired={ariaRequired}
clearAriaLabel={clearAriaLabel}
isEmpty={isEmpty && !dropdownStatus.content}

Check failure on line 205 in src/autosuggest/internal.tsx

View workflow job for this annotation

GitHub Actions / build / build

Type '{ className: string; ref: RefObject<AutosuggestInputRef>; __internalRootRef: MutableRefObject<any> | null | undefined; value: string; ... 37 more ...; errorIconAriaLabel?: string | undefined; }' is not assignable to type 'IntrinsicAttributes & AutosuggestInputProps & RefAttributes<AutosuggestInputRef>'.

Check failure on line 205 in src/autosuggest/internal.tsx

View workflow job for this annotation

GitHub Actions / Test for regressions

Type '{ className: string; ref: RefObject<AutosuggestInputRef>; __internalRootRef: MutableRefObject<any> | null | undefined; value: string; ... 37 more ...; errorIconAriaLabel?: string | undefined; }' is not assignable to type 'IntrinsicAttributes & AutosuggestInputProps & RefAttributes<AutosuggestInputRef>'.
disableBrowserAutocorrect={disableBrowserAutocorrect}
expandToViewport={expandToViewport}
ariaControls={listId}
Expand Down
5 changes: 3 additions & 2 deletions src/internal/components/autosuggest-input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const AutosuggestInput = React.forwardRef(
onPressArrowDown,
onPressArrowUp,
onPressEnter,
isEmpty,

Check failure on line 94 in src/internal/components/autosuggest-input/index.tsx

View workflow job for this annotation

GitHub Actions / build / build

Property 'isEmpty' does not exist on type 'AutosuggestInputProps'.

Check failure on line 94 in src/internal/components/autosuggest-input/index.tsx

View workflow job for this annotation

GitHub Actions / Test for regressions

Property 'isEmpty' does not exist on type 'AutosuggestInputProps'.
__internalRootRef,
...restProps
}: AutosuggestInputProps,
Expand Down Expand Up @@ -249,7 +250,6 @@ const AutosuggestInput = React.forwardRef(

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open]);

return (
<div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={__internalRootRef}>
<Dropdown
Expand All @@ -259,6 +259,7 @@ const AutosuggestInput = React.forwardRef(
contentKey={dropdownContentKey}
onFocus={handleFocus}
onBlur={handleBlur}
isEmpty={isEmpty}

Check failure on line 262 in src/internal/components/autosuggest-input/index.tsx

View workflow job for this annotation

GitHub Actions / build / build

Type '{ children: Element | null; minWidth: number | undefined; stretchWidth: boolean; stretchBeyondTriggerWidth: true; contentKey: string | undefined; onFocus: () => void; onBlur: () => void; ... 6 more ...; loopFocus: boolean | undefined; }' is not assignable to type 'IntrinsicAttributes & DropdownProps'.

Check failure on line 262 in src/internal/components/autosuggest-input/index.tsx

View workflow job for this annotation

GitHub Actions / Test for regressions

Type '{ children: Element | null; minWidth: number | undefined; stretchWidth: boolean; stretchBeyondTriggerWidth: true; contentKey: string | undefined; onFocus: () => void; onBlur: () => void; ... 6 more ...; loopFocus: boolean | undefined; }' is not assignable to type 'IntrinsicAttributes & DropdownProps'.
trigger={
<InternalInput
type="visualSearch"
Expand All @@ -279,7 +280,7 @@ const AutosuggestInput = React.forwardRef(
/>
}
onMouseDown={handleDropdownMouseDown}
open={open && !!dropdownContent}
open={true}
footer={
dropdownFooterRef && (
<div ref={dropdownFooterRef} className={styles['dropdown-footer']}>
Expand Down
28 changes: 18 additions & 10 deletions src/internal/components/dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,18 @@ const TransitionContent = ({
role,
ariaLabelledby,
ariaDescribedby,
isEmpty,

Check failure on line 94 in src/internal/components/dropdown/index.tsx

View workflow job for this annotation

GitHub Actions / build / build

Property 'isEmpty' does not exist on type 'TransitionContentProps'.

Check failure on line 94 in src/internal/components/dropdown/index.tsx

View workflow job for this annotation

GitHub Actions / Test for regressions

Property 'isEmpty' does not exist on type 'TransitionContentProps'.
}: TransitionContentProps) => {
const contentRef = useMergeRefs(dropdownRef, transitionRef);
console.log({ header, children, isEmpty });
return (
<div
className={clsx(styles.dropdown, dropdownClasses, {
[styles.open]: open,
[styles['with-limited-width']]: !stretchWidth,
[styles['hide-upper-border']]: stretchWidth,
[styles.interior]: interior,
[styles['is-empty']]: !header && !children,
// [styles['is-empty']]: !header && !children,
[styles.refresh]: isRefresh,
[styles['use-portal']]: expandToViewport && !interior,
[styles['stretch-beyond-trigger-width']]: stretchBeyondTriggerWidth,
Expand All @@ -116,15 +118,19 @@ const TransitionContent = ({
style={stretchBeyondTriggerWidth ? { maxWidth: defaultMaxDropdownWidth } : {}}
onMouseDown={onMouseDown}
>
<div className={clsx(styles['dropdown-content-wrapper'], isRefresh && styles.refresh)}>
<div className={styles['ie11-wrapper']}>
<div ref={verticalContainerRef} className={styles['dropdown-content']}>
<DropdownContextProvider position={position}>
{header}
{children}
{footer}
</DropdownContextProvider>
</div>
<div
className={clsx(
styles['dropdown-content-wrapper'],
!header && isEmpty && styles['is-empty'],
isRefresh && styles.refresh
)}
>
<div ref={verticalContainerRef} className={styles['dropdown-content']}>
<DropdownContextProvider position={position}>
{header}
{children}
{footer}
</DropdownContextProvider>
</div>
</div>
</div>
Expand Down Expand Up @@ -158,6 +164,7 @@ const Dropdown = ({
dropdownContentRole,
ariaLabelledby,
ariaDescribedby,
isEmpty,

Check failure on line 167 in src/internal/components/dropdown/index.tsx

View workflow job for this annotation

GitHub Actions / build / build

Property 'isEmpty' does not exist on type 'DropdownProps'.

Check failure on line 167 in src/internal/components/dropdown/index.tsx

View workflow job for this annotation

GitHub Actions / Test for regressions

Property 'isEmpty' does not exist on type 'DropdownProps'.
}: DropdownProps) => {
const wrapperRef = useRef<HTMLDivElement | null>(null);
const triggerRef = useRef<HTMLDivElement | null>(null);
Expand Down Expand Up @@ -426,6 +433,7 @@ const Dropdown = ({
role={dropdownContentRole}
ariaLabelledby={ariaLabelledby}
ariaDescribedby={ariaDescribedby}
isEmpty={isEmpty}

Check failure on line 436 in src/internal/components/dropdown/index.tsx

View workflow job for this annotation

GitHub Actions / build / build

Type '{ children: ReactNode; state: TransitionStatus; transitionRef: MutableRefObject<any>; dropdownClasses: string; open: boolean | undefined; ... 15 more ...; isEmpty: any; }' is not assignable to type 'IntrinsicAttributes & TransitionContentProps'.

Check failure on line 436 in src/internal/components/dropdown/index.tsx

View workflow job for this annotation

GitHub Actions / Test for regressions

Type '{ children: ReactNode; state: TransitionStatus; transitionRef: MutableRefObject<any>; dropdownClasses: string; open: boolean | undefined; ... 15 more ...; isEmpty: any; }' is not assignable to type 'IntrinsicAttributes & TransitionContentProps'.
>
{children}
</TransitionContent>
Expand Down
16 changes: 5 additions & 11 deletions src/internal/components/dropdown/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
}

border-bottom: none;

// Don't show dropdown border when there's no dropdown content
&.is-empty::after {
display: none;
}
}

&-drop-up {
Expand Down Expand Up @@ -96,10 +101,6 @@
overflow: scroll;
}
}
// Don't show dropdown border when there's no dropdown content
&.is-empty::after {
display: none;
}
}

.dropdown-content {
Expand All @@ -108,13 +109,6 @@
width: 100%;
}

// Child flex wrapper used because when combining an absolute position
// and flexbox, IE11 will incorrectly size the container according to its parent
// and not its content.
.ie11-wrapper {
display: flex;
}

.stretch-trigger-height {
height: 100%;
}

0 comments on commit 4f46fb7

Please sign in to comment.