Skip to content

Commit

Permalink
FIX: Disable floating label for date types
Browse files Browse the repository at this point in the history
  • Loading branch information
hlimas committed Oct 13, 2023
1 parent 027836a commit f46c110
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/common/floating-label-utils/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import classNames from 'classnames'

type InputRef = RefObject<HTMLSelectElement | HTMLTextAreaElement | HTMLInputElement> | any
type FloatingLabelHookProps = {
type?: string;
inputId?: string;
ref?: InputRef;
disabled?: boolean;
Expand Down Expand Up @@ -78,6 +79,7 @@ export function useFloatingLabel({
placeholder,
invalid,
opaqueLabel,
type,
onMount = () => {}
} : FloatingLabelHookProps): FloatingLabelHookReturn {
const _internalInputRef = useRef(null)
Expand Down Expand Up @@ -120,7 +122,7 @@ export function useFloatingLabel({
const labelClassName = classNames(className, classPrefix, {
[`${classPrefix}--disabled`]: disabled,
[`${classPrefix}--animate`]: shouldAnimate,
[`${classPrefix}--inline`]: !isFloating,
[`${classPrefix}--inline`]: !isFloating && type !== 'date',
[`${classPrefix}--invalid`]: invalid
})

Expand Down
23 changes: 23 additions & 0 deletions src/ebay-textbox/__tests__/__snapshots__/index.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,29 @@ exports[`Storyshots ebay-textbox Floating label invalid 1`] = `
</DocumentFragment>
`;

exports[`Storyshots ebay-textbox Floating label type date 1`] = `
<DocumentFragment>
<span
class="floating-label"
>
<label
class="floating-label__label"
>
Floating label
</label>
<span
class="textbox"
>
<input
class="textbox__control"
type="date"
value=""
/>
</span>
</span>
</DocumentFragment>
`;

exports[`Storyshots ebay-textbox Floating label with autofocus 1`] = `
<DocumentFragment>
<p>
Expand Down
9 changes: 9 additions & 0 deletions src/ebay-textbox/__tests__/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ storiesOf('ebay-textbox', module)
onFloatingLabelInit={() => action('onFloatingLabelInit')()}
/>
))
.add('Floating label type date', () => (
<EbayTextbox
type="date"
floatingLabel="Floating label"
onChange={action('onChange')}
onInputChange={action('onInputChange')}
onFloatingLabelInit={() => action('onFloatingLabelInit')()}
/>
))
.add('Floating label with value', () => (
<EbayTextbox
onChange={action('textbox-changed')}
Expand Down
1 change: 1 addition & 0 deletions src/ebay-textbox/textbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const EbayTextbox: FC<EbayTextboxProps> = ({
inputValue: controlledValue || inputValue,
placeholder,
invalid,
type,
opaqueLabel,
onMount: onFloatingLabelInit
})
Expand Down

0 comments on commit f46c110

Please sign in to comment.