Skip to content

Commit

Permalink
[fix](@svelteui/core): fix no pointer events in Input right section
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #446
  • Loading branch information
BeeMargarida committed Aug 21, 2023
1 parent cba20e2 commit bab15a5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { Meta, Template, Story } from '@storybook/addon-svelte-csf';
import { Input } from './index';
import { EnvelopeClosed } from 'radix-icons-svelte';
import { Button } from '../Button';
let value = 'Hello';
let valueNumber = 0;
Expand Down Expand Up @@ -38,3 +39,11 @@
</svelte:fragment>
</Input>
</Story>

<Story name="With right section" id="inputRightSectionStory">
<Input bind:value>
<svelte:fragment slot="rightSection">
<Button on:click={() => console.log('heelo')} />
</svelte:fragment>
</Input>
</Story>
4 changes: 3 additions & 1 deletion packages/svelteui-core/src/components/Input/Input.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,10 @@ export default createStyles(
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
pointerEvents: 'none',
width: rightSectionWidth
},
noPointerEvents: {
pointerEvents: 'none'
}
};
}
Expand Down
8 changes: 7 additions & 1 deletion packages/svelteui-core/src/components/Input/Input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
function isInput(root: string): root is Input {
return ['input', 'select', 'textarea', 'datalist'].includes(root);
}
function isSelect(root: string): boolean {
return root === 'select';
}
let isHTMLElement = true;
let isComponent = false;
Expand Down Expand Up @@ -226,7 +229,10 @@ Base component to create custom inputs
</div>
{/if}
{#if showRightSection}
<div {...rightSectionProps} class={classes.rightSection}>
<div
{...rightSectionProps}
class={cx(classes.rightSection, { [classes.noPointerEvents]: isSelect(root) })}
>
<slot name="rightSection" />
</div>
{/if}
Expand Down

0 comments on commit bab15a5

Please sign in to comment.