Comments (2)
It's working now. Thank you for your fastly answer @endigo9740. Here is my code for anyone needed.
<script lang="ts">
import {
InputChip,
Autocomplete,
popup,
type PopupSettings,
type AutocompleteOption,
} from '@skeletonlabs/skeleton';
import type { SizeOptions } from '@floating-ui/dom';
import { uniqueId } from 'lodash';
let inputChip = '';
let inputChipList = ['vanilla', 'chocolate'];
type FlavorOption = AutocompleteOption<string, { healthy: boolean }>;
const flavorOptions: FlavorOption[] = [
{ label: 'Vanilla', value: 'vanilla', keywords: 'plain, basic', meta: { healthy: false } },
{ label: 'Chocolate', value: 'chocolate', keywords: 'dark, white', meta: { healthy: false } },
{ label: 'Strawberry', value: 'strawberry', keywords: 'fruit', meta: { healthy: true } },
{
label: 'Neapolitan',
value: 'neapolitan',
keywords: 'mix, strawberry, chocolate, vanilla',
meta: { healthy: false },
},
{ label: 'Pineapple', value: 'pineapple', keywords: 'fruit', meta: { healthy: true } },
{ label: 'Peach', value: 'peach', keywords: 'fruit', meta: { healthy: true } },
];
function onInputChipSelect(event: CustomEvent<FlavorOption>): void {
console.log('onInputChipSelect', event.detail);
if (inputChipList.includes(event.detail.value) === false) {
inputChipList = [...inputChipList, event.detail.value];
inputChip = '';
}
}
const uuid = uniqueId('multiple-select-popup');
let popupSettings: PopupSettings = {
event: 'focus-click',
target: uuid,
placement: 'bottom-start',
middleware: {
shift: {
padding: 0,
},
offset: 0,
size: {
apply({ rects, elements }) {
Object.assign(elements.floating.style, {
width: `${rects.reference.width}px`,
});
},
} as SizeOptions,
},
};
</script>
<div use:popup={popupSettings} class="w-full">
<InputChip bind:input={inputChip} bind:value={inputChipList} name="chips" />
<div data-popup={popupSettings.target} class={`card max-h-48 overflow-y-auto`} tabindex="-1">
<Autocomplete
bind:input={inputChip}
options={flavorOptions}
denylist={inputChipList}
on:selection={onInputChipSelect} />
</div>
</div>
from skeleton.
@vuthanhdanh080200 so in your screenshot it looks like your trigger element is very close to the edge of the visible screen. This is notable because Floating UI provides several middleware options for controlling position, including one called shift:
https://floating-ui.com/docs/shift
We utilize this in the popup's default settings, which you can see here:
https://github.com/skeletonlabs/skeleton/blob/master/packages/skeleton/src/lib/utilities/Popup/popup.ts#L59
This essentially sets a padding offset of 8px away from the edge of the screen, so it will never be flush like you may be expecting. This is configurable though, which we cover in the Middleware docs here:
https://www.skeleton.dev/utilities/popups#middleware
Feel free to adjust as needed.
Given this is intended behavior, not a bug, I'll go ahead and close this issue. But if you any follow up questions, feel free to reach out and I'll respond (though it may be tomorrow my time).
from skeleton.
Related Issues (20)
- Some v2 doc images are not displaying HOT 1
- Integration: Data Visualization
- v3 Custom Theme Doc Errors
- v3 Tailwind > Gradients CSS button has broken link
- Review "RestProps" spread method for arbitrary attributes HOT 2
- v3 Switch Component - Quick Patch
- computed styles not being applied HOT 3
- Repeated word in Docs HOT 1
- Audio/video components
- Svelte v5 RC: InputChip component produces errors HOT 9
- v3 React AppBar does not follow export conventions HOT 1
- v3 - consistency -D and --save-dev HOT 6
- TreeView - Custom Icons. HOT 1
- Carousel seems broken on doc page HOT 1
- Refactor React components to fall more inline with existing React libraries HOT 4
- RFC: Remove return types from React components
- A little bit of white peeking out on the progress bars (styling issue) HOT 3
- InputChips does not have restProps HOT 2
- Table of Contents: support setting scrollTarget, scrollOffset HOT 1
- AppRailTile on:click not working (v2.10.1) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skeleton.