-
Notifications
You must be signed in to change notification settings - Fork 309
Dismissable #1700
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
base: main
Are you sure you want to change the base?
Dismissable #1700
Conversation
@jjagielka is attempting to deploy a commit to the Themesberg Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughA dismissable context mechanism has been introduced for Svelte components, enabling standardized dismissal behavior. The Badge, Alert, Banner, Modal, Toast, and various form components now use this context for their close or clear functionality, while the CloseButton component consumes the context to trigger dismissal actions. A new utility module implements the context provider and consumer logic. Additionally, multiple drawer example components and documentation were updated to remove explicit inline click handlers from CloseButton components. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CloseButton
participant DismissableContext
participant Component
User->>CloseButton: Clicks close button
CloseButton->>DismissableContext: Calls dismiss(event)
DismissableContext->>Component: Invokes close(event)
Component->>Component: Dispatches "close" event
alt Event not prevented
Component->>Component: Updates internal state (hide/dismiss)
else Event prevented
Component->>Component: No state change
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Possibly related PRs
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This seems easier to apply and also cleaner, scalable, flexible. |
useDismiss() returns undefined and logs a warning — which is okay in dev, but we may need to consider throwing in production? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
src/lib/alert/Alert.svelte (1)
79-79
: Remove outdated prop documentationThe
onclick
prop has been replaced withonclose
but the documentation still references it.-@prop onclick = ()
🧹 Nitpick comments (4)
src/lib/toast/Toast.svelte (1)
32-36
: Consider using a more generic event typeThe
_close
function parameter is typed asMouseEvent
, but the dismissable context might be triggered by keyboard events or other interactions. Consider usingEvent
for broader compatibility.-function _close(event: MouseEvent) { +function _close(event: Event) { if (ref?.dispatchEvent(new Event("close", { bubbles: true, cancelable: true }))) { toastStatus = false; } }src/lib/banner/Banner.svelte (1)
21-25
: Consider using a more generic event typeSame as in Toast.svelte, the
close
function parameter should useEvent
instead ofMouseEvent
for broader compatibility.-function close(event: MouseEvent) { +function close(event: Event) { if (ref?.dispatchEvent(new Event("close", { bubbles: true, cancelable: true }))) { open = false; } }src/lib/alert/Alert.svelte (1)
27-31
: Consider using a more generic event typeConsistent with other components, use
Event
instead ofMouseEvent
for the close function parameter.-function close(event: MouseEvent) { +function close(event: Event) { if (ref?.dispatchEvent(new Event("close", { bubbles: true, cancelable: true }))) { alertStatus = false; } }src/lib/modal/Modal.svelte (1)
90-97
: Consider using a more generic event typeFor consistency with other components and broader compatibility, use
Event
instead ofMouseEvent
.-function close_handler(ev: MouseEvent) { +function close_handler(ev: Event) { if (form) { // dialog/form mechanism will close the dialog return; } ref?.dispatchEvent(new Event("cancel", { bubbles: true, cancelable: true })); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
src/lib/alert/Alert.svelte
(3 hunks)src/lib/badge/Badge.svelte
(3 hunks)src/lib/banner/Banner.svelte
(2 hunks)src/lib/modal/Modal.svelte
(4 hunks)src/lib/toast/Toast.svelte
(3 hunks)src/lib/utils/CloseButton.svelte
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/lib/utils/CloseButton.svelte
- src/lib/badge/Badge.svelte
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: mrh1997
PR: themesberg/flowbite-svelte#1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In `src/lib/utils/Popper.svelte`, inconsistencies in event handling (e.g., using both `mouseenter`/`mouseleave` and `pointerenter`/`pointerleave`) may be intentional to minimize modifications and reduce the risk of new problems.
src/lib/toast/Toast.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/lib/alert/Alert.svelte (2)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
Learnt from: LahTeuto
PR: #1484
File: src/lib/navbar/NavLi.svelte:34-34
Timestamp: 2024-11-12T10:36:34.807Z
Learning: When enhancing ARIA roles in Svelte components, avoid setting role="presentation"
on elements that should retain the link
role, as it can diminish ARIA role coverage and negatively affect accessibility.
src/lib/banner/Banner.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/lib/modal/Modal.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
🔇 Additional comments (1)
src/lib/modal/Modal.svelte (1)
90-99
: Good handling of form/dialog interactionThe check for
form
prop before dispatching the cancel event is correct, as it prevents interference with the native dialog/form closing mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/lib/drawer/Drawer.svelte (1)
60-60
: Update inline documentation.The comment block still references the old
closeDrawer
prop which has been replaced withonclose
.-@prop closeDrawer = () +@prop onclosesrc/lib/toast/Toast.svelte (1)
34-38
: Consider more flexible parameter typing.The event dispatching logic is well-designed with proper cancelable event handling. However, the
event: MouseEvent
parameter might be too restrictive since this function could be called from various contexts through the dismissable context.Consider using a more flexible parameter type:
-function _close(event: MouseEvent) { +function _close(event?: Event) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (36)
src/lib/drawer/Drawer.svelte
(2 hunks)src/lib/forms/fileupload/Fileupload.svelte
(2 hunks)src/lib/forms/floating-label/FloatingLabelInput.svelte
(3 hunks)src/lib/forms/input-field/Input.svelte
(3 hunks)src/lib/forms/search/Search.svelte
(3 hunks)src/lib/forms/select/MultiSelect.svelte
(3 hunks)src/lib/forms/select/Select.svelte
(3 hunks)src/lib/forms/textarea/Textarea.svelte
(3 hunks)src/lib/toast/Toast.svelte
(3 hunks)src/lib/utils/dismissable.svelte.ts
(1 hunks)src/routes/api-check/components/drawer/examples/Bottom.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/Contact.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/Default.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/Disabled.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/DisablingOutside.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/Enabled.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/Form.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/Left.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/Navigation.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/OnlyOutside.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/Position.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/Right.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/Scrolling.svelte
(1 hunks)src/routes/api-check/components/drawer/examples/Top.svelte
(1 hunks)src/routes/api-check/forms/timepicker.svelte
(1 hunks)src/routes/docs/components/drawer.md
(14 hunks)src/routes/docs/components/toast.md
(2 hunks)src/routes/docs/forms/checkbox.md
(6 hunks)src/routes/docs/forms/input-field.md
(1 hunks)src/routes/docs/forms/radio.md
(4 hunks)src/routes/docs/forms/search-input.md
(3 hunks)src/routes/docs/forms/timepicker.md
(1 hunks)src/routes/docs/forms/toggle.md
(1 hunks)src/routes/examples/drawer/classesCheck.svelte
(1 hunks)static/llm/components/drawer.md
(14 hunks)static/llm/forms/timepicker.md
(1 hunks)
✅ Files skipped from review due to trivial changes (5)
- src/routes/docs/components/drawer.md
- static/llm/components/drawer.md
- src/routes/docs/forms/checkbox.md
- src/routes/docs/forms/search-input.md
- src/lib/utils/dismissable.svelte.ts
🧰 Additional context used
🧠 Learnings (28)
📓 Common learnings
Learnt from: mrh1997
PR: themesberg/flowbite-svelte#1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In `src/lib/utils/Popper.svelte`, inconsistencies in event handling (e.g., using both `mouseenter`/`mouseleave` and `pointerenter`/`pointerleave`) may be intentional to minimize modifications and reduce the risk of new problems.
Learnt from: Chizaruu
PR: themesberg/flowbite-svelte#1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In `Timepicker.svelte`, the `Dropdown` opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.
Learnt from: LahTeuto
PR: themesberg/flowbite-svelte#1484
File: src/lib/navbar/NavLi.svelte:34-34
Timestamp: 2024-11-12T10:36:34.807Z
Learning: When enhancing ARIA roles in Svelte components, avoid setting `role="presentation"` on elements that should retain the `link` role, as it can diminish ARIA role coverage and negatively affect accessibility.
src/routes/examples/drawer/classesCheck.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/routes/api-check/components/drawer/examples/Scrolling.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/routes/api-check/components/drawer/examples/Right.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/routes/api-check/components/drawer/examples/Navigation.svelte (2)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
Learnt from: LahTeuto
PR: #1484
File: src/lib/navbar/NavLi.svelte:34-34
Timestamp: 2024-11-12T10:36:34.807Z
Learning: When enhancing ARIA roles in Svelte components, avoid setting role="presentation"
on elements that should retain the link
role, as it can diminish ARIA role coverage and negatively affect accessibility.
src/routes/api-check/components/drawer/examples/Enabled.svelte (2)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
Learnt from: LahTeuto
PR: #1484
File: src/lib/navbar/NavLi.svelte:34-34
Timestamp: 2024-11-12T10:36:34.807Z
Learning: When enhancing ARIA roles in Svelte components, avoid setting role="presentation"
on elements that should retain the link
role, as it can diminish ARIA role coverage and negatively affect accessibility.
src/routes/api-check/components/drawer/examples/Top.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/routes/api-check/components/drawer/examples/Default.svelte (2)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
Learnt from: LahTeuto
PR: #1484
File: src/lib/navbar/NavLi.svelte:34-34
Timestamp: 2024-11-12T10:36:34.807Z
Learning: When enhancing ARIA roles in Svelte components, avoid setting role="presentation"
on elements that should retain the link
role, as it can diminish ARIA role coverage and negatively affect accessibility.
src/routes/api-check/components/drawer/examples/Left.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/routes/api-check/components/drawer/examples/Position.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/lib/forms/select/Select.svelte (2)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
Learnt from: Chizaruu
PR: #1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In Timepicker.svelte
, the Dropdown
opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.
src/routes/api-check/components/drawer/examples/DisablingOutside.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/routes/docs/forms/timepicker.md (3)
Learnt from: Chizaruu
PR: #1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In Timepicker.svelte
, the Dropdown
opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.
Learnt from: Chizaruu
PR: #1464
File: src/routes/component-data/Datepicker.json:0-0
Timestamp: 2024-10-15T22:41:47.429Z
Learning: The component should be named 'Datepicker' (with lowercase 'p') throughout the codebase to maintain consistency.
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/routes/api-check/components/drawer/examples/Bottom.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/routes/api-check/components/drawer/examples/Contact.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/lib/forms/floating-label/FloatingLabelInput.svelte (7)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:11:53.953Z
Learning: In the Flowbite Svelte library's MultiInput component, the 'inputInvalid' property should be exported and passed to the Wrapper component to properly style the component's ring with red color when validation fails, similar to how the Input component handles validation states.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T12:47:33.307Z
Learning: In the Flowbite Svelte library's composite form components like MultiInput, when implementing focus styles, ensure both the container (with focus-within) and the inner input element (with direct focus) have dynamic styling based on the validation state. The input element needs its own focus styles that change to red when inputInvalid=true.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:11:53.952Z
Learning: In the Flowbite Svelte library, when implementing components with validation states, the 'inputInvalid' property should be explicitly defined and passed to the Wrapper component. When inputInvalid=true, the color should be set to "red" to ensure the ring/border styling is applied correctly.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:52:09.106Z
Learning: In the Flowbite Svelte library's form components like MultiInput, when handling focus states for validation, avoid hardcoding focus-within classes like 'focus-within:border-primary-500'. Instead, create a dynamic mapping object (e.g., focusWithinClasses) that changes the focus ring color based on the current color state, especially when inputInvalid=true.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T12:47:33.307Z
Learning: In the Flowbite Svelte library's composite form components like MultiInput, when implementing focus styles with focus-within, create a dedicated focusWithinClasses object with appropriate colors for each state (base, primary, green, red). Using just 'focus-within:ring-1' without color specification won't correctly apply color-specific styling when the input receives focus directly.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:52:09.106Z
Learning: In the Flowbite Svelte library's form components, both the regular focus styling (controlled by ringClasses) and focus-within styling need to be dynamically adjusted based on validation state. For proper validation styling, create separate objects for focus-within classes (like focusWithinClasses) that use the same color as ringClasses when inputInvalid=true.
static/llm/forms/timepicker.md (3)
Learnt from: Chizaruu
PR: #1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In Timepicker.svelte
, the Dropdown
opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.
Learnt from: Chizaruu
PR: #1464
File: src/routes/component-data/Datepicker.json:0-0
Timestamp: 2024-10-15T22:41:47.429Z
Learning: The component should be named 'Datepicker' (with lowercase 'p') throughout the codebase to maintain consistency.
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/lib/forms/select/MultiSelect.svelte (2)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
Learnt from: Chizaruu
PR: #1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In Timepicker.svelte
, the Dropdown
opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.
src/lib/forms/search/Search.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/routes/docs/forms/radio.md (5)
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T12:47:33.307Z
Learning: In the Flowbite Svelte library's composite form components like MultiInput, when implementing focus styles with focus-within, create a dedicated focusWithinClasses object with appropriate colors for each state (base, primary, green, red). Using just 'focus-within:ring-1' without color specification won't correctly apply color-specific styling when the input receives focus directly.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:52:09.106Z
Learning: In the Flowbite Svelte library's form components, both the regular focus styling (controlled by ringClasses) and focus-within styling need to be dynamically adjusted based on validation state. For proper validation styling, create separate objects for focus-within classes (like focusWithinClasses) that use the same color as ringClasses when inputInvalid=true.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:11:53.952Z
Learning: In the Flowbite Svelte library, when implementing components with validation states, the 'inputInvalid' property should be explicitly defined and passed to the Wrapper component. When inputInvalid=true, the color should be set to "red" to ensure the ring/border styling is applied correctly.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:52:09.106Z
Learning: In the Flowbite Svelte library's form components like MultiInput, when handling focus states for validation, avoid hardcoding focus-within classes like 'focus-within:border-primary-500'. Instead, create a dynamic mapping object (e.g., focusWithinClasses) that changes the focus ring color based on the current color state, especially when inputInvalid=true.
Learnt from: LahTeuto
PR: #1484
File: src/lib/navbar/NavLi.svelte:34-34
Timestamp: 2024-11-12T10:36:34.807Z
Learning: When enhancing ARIA roles in Svelte components, avoid setting role="presentation"
on elements that should retain the link
role, as it can diminish ARIA role coverage and negatively affect accessibility.
src/routes/api-check/components/drawer/examples/Form.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/routes/api-check/components/drawer/examples/Disabled.svelte (2)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
Learnt from: LahTeuto
PR: #1484
File: src/lib/navbar/NavLi.svelte:34-34
Timestamp: 2024-11-12T10:36:34.807Z
Learning: When enhancing ARIA roles in Svelte components, avoid setting role="presentation"
on elements that should retain the link
role, as it can diminish ARIA role coverage and negatively affect accessibility.
src/routes/api-check/components/drawer/examples/OnlyOutside.svelte (2)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
Learnt from: LahTeuto
PR: #1484
File: src/lib/navbar/NavLi.svelte:34-34
Timestamp: 2024-11-12T10:36:34.807Z
Learning: When enhancing ARIA roles in Svelte components, avoid setting role="presentation"
on elements that should retain the link
role, as it can diminish ARIA role coverage and negatively affect accessibility.
src/routes/api-check/forms/timepicker.svelte (2)
Learnt from: Chizaruu
PR: #1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In Timepicker.svelte
, the Dropdown
opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/lib/forms/input-field/Input.svelte (8)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:11:53.953Z
Learning: In the Flowbite Svelte library's MultiInput component, the 'inputInvalid' property should be exported and passed to the Wrapper component to properly style the component's ring with red color when validation fails, similar to how the Input component handles validation states.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:52:09.106Z
Learning: In the Flowbite Svelte library's form components like MultiInput, when handling focus states for validation, avoid hardcoding focus-within classes like 'focus-within:border-primary-500'. Instead, create a dynamic mapping object (e.g., focusWithinClasses) that changes the focus ring color based on the current color state, especially when inputInvalid=true.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T12:47:33.307Z
Learning: In the Flowbite Svelte library's composite form components like MultiInput, when implementing focus styles, ensure both the container (with focus-within) and the inner input element (with direct focus) have dynamic styling based on the validation state. The input element needs its own focus styles that change to red when inputInvalid=true.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:11:53.952Z
Learning: In the Flowbite Svelte library, when implementing components with validation states, the 'inputInvalid' property should be explicitly defined and passed to the Wrapper component. When inputInvalid=true, the color should be set to "red" to ensure the ring/border styling is applied correctly.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T12:47:33.307Z
Learning: In the Flowbite Svelte library's composite form components like MultiInput, when implementing focus styles with focus-within, create a dedicated focusWithinClasses object with appropriate colors for each state (base, primary, green, red). Using just 'focus-within:ring-1' without color specification won't correctly apply color-specific styling when the input receives focus directly.
Learnt from: Chizaruu
PR: #1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In Timepicker.svelte
, the Dropdown
opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:52:09.106Z
Learning: In the Flowbite Svelte library's form components, both the regular focus styling (controlled by ringClasses) and focus-within styling need to be dynamically adjusted based on validation state. For proper validation styling, create separate objects for focus-within classes (like focusWithinClasses) that use the same color as ringClasses when inputInvalid=true.
src/lib/toast/Toast.svelte (1)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
src/lib/drawer/Drawer.svelte (3)
Learnt from: mrh1997
PR: #1442
File: src/lib/utils/Popper.svelte:144-145
Timestamp: 2024-11-22T08:37:27.996Z
Learning: In src/lib/utils/Popper.svelte
, inconsistencies in event handling (e.g., using both mouseenter
/mouseleave
and pointerenter
/pointerleave
) may be intentional to minimize modifications and reduce the risk of new problems.
Learnt from: LahTeuto
PR: #1484
File: src/lib/navbar/NavLi.svelte:34-34
Timestamp: 2024-11-12T10:36:34.807Z
Learning: When enhancing ARIA roles in Svelte components, avoid setting role="presentation"
on elements that should retain the link
role, as it can diminish ARIA role coverage and negatively affect accessibility.
Learnt from: Chizaruu
PR: #1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In Timepicker.svelte
, the Dropdown
opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.
src/routes/docs/forms/input-field.md (5)
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:52:09.106Z
Learning: In the Flowbite Svelte library's form components, both the regular focus styling (controlled by ringClasses) and focus-within styling need to be dynamically adjusted based on validation state. For proper validation styling, create separate objects for focus-within classes (like focusWithinClasses) that use the same color as ringClasses when inputInvalid=true.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:52:09.106Z
Learning: In the Flowbite Svelte library's form components like MultiInput, when handling focus states for validation, avoid hardcoding focus-within classes like 'focus-within:border-primary-500'. Instead, create a dynamic mapping object (e.g., focusWithinClasses) that changes the focus ring color based on the current color state, especially when inputInvalid=true.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T12:47:33.307Z
Learning: In the Flowbite Svelte library's composite form components like MultiInput, when implementing focus styles with focus-within, create a dedicated focusWithinClasses object with appropriate colors for each state (base, primary, green, red). Using just 'focus-within:ring-1' without color specification won't correctly apply color-specific styling when the input receives focus directly.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:11:53.953Z
Learning: In the Flowbite Svelte library's MultiInput component, the 'inputInvalid' property should be exported and passed to the Wrapper component to properly style the component's ring with red color when validation fails, similar to how the Input component handles validation states.
Learnt from: superstes
PR: themesberg/flowbite-svelte#0
File: :0-0
Timestamp: 2025-03-20T11:11:53.952Z
Learning: In the Flowbite Svelte library, when implementing components with validation states, the 'inputInvalid' property should be explicitly defined and passed to the Wrapper component. When inputInvalid=true, the color should be set to "red" to ensure the ring/border styling is applied correctly.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Playwright and Lint
🔇 Additional comments (45)
src/routes/api-check/components/drawer/examples/OnlyOutside.svelte (1)
17-17
: LGTM! CloseButton now uses dismissable context.The removal of the explicit
onclick
handler aligns with the new dismissable context pattern. The CloseButton should now automatically handle drawer dismissal through the context mechanism, which is cleaner and more maintainable than requiring explicit handlers in every usage.src/routes/examples/drawer/classesCheck.svelte (1)
16-16
: Consistent with dismissable context pattern.The removal of the explicit
onclick
handler is consistent with the new dismissable context approach being implemented across drawer examples. This centralizes dismiss functionality while maintaining the same user experience.src/routes/api-check/components/drawer/examples/Top.svelte (1)
23-23
: Dismissable context applied consistently across drawer variants.Good to see the dismissable context pattern being applied consistently across different drawer configurations (placement, transitions). This demonstrates proper separation of concerns between dismiss functionality and drawer positioning/animation.
src/routes/api-check/components/drawer/examples/Disabled.svelte (1)
17-17
: Dismissable context works independently of backdrop settings.The dismissable context pattern is properly applied here. Good to see that the CloseButton dismiss functionality is independent of the drawer's backdrop configuration, maintaining proper separation of concerns.
src/routes/api-check/components/drawer/examples/Form.svelte (1)
16-16
: Final confirmation of consistent dismissable context implementation.Excellent consistency in applying the dismissable context pattern across all drawer examples. The CloseButton now handles dismissal through context, which is cleaner and more maintainable than explicit handlers. This approach scales well across different drawer configurations and content types.
src/routes/api-check/components/drawer/examples/Enabled.svelte (1)
17-17
: LGTM! Dismissable context implementation.The removal of the inline
onclick
handler aligns with the new dismissable context pattern. TheCloseButton
will now use the context-based dismissal mechanism internally, providing cleaner and more consistent behavior across components.src/routes/docs/forms/timepicker.md (1)
507-507
: Documentation updated to reflect dismissable context pattern.The removal of the inline
onclick
handler from theCloseButton
in this drawer example aligns with the systematic refactor to use dismissable context. This ensures documentation examples remain consistent with the new implementation pattern.src/routes/api-check/components/drawer/examples/Left.svelte (1)
17-17
: Consistent with dismissable context refactor.The removal of the inline
onclick
handler fromCloseButton
is consistent with the systematic refactor to implement dismissable context across drawer examples. This improves code consistency and maintainability.src/routes/api-check/components/drawer/examples/Default.svelte (1)
17-17
: Default drawer example updated for dismissable context.The removal of the inline
onclick
handler fromCloseButton
in the default drawer example is consistent with the dismissable context refactor. As this is likely a frequently referenced example, the implementation correctly demonstrates the new pattern.src/routes/api-check/components/drawer/examples/Bottom.svelte (1)
23-23
: Bottom drawer example consistent with dismissable pattern.The removal of the inline
onclick
handler fromCloseButton
completes the consistent implementation of dismissable context across drawer examples. The bottom-positioned drawer maintains its custom transition parameters while adopting the new dismissal pattern.src/routes/api-check/forms/timepicker.svelte (1)
435-435
: Good architectural improvement using dismissable context.The removal of the inline
onclick
handler aligns with the new dismissable context pattern, promoting consistent and centralized dismissal behavior across components.src/routes/api-check/components/drawer/examples/Position.svelte (1)
17-17
: Consistent with dismissable context refactor.The removal of the explicit
onclick
handler is part of the broader architectural improvement to standardize dismissal behavior through context.src/routes/api-check/components/drawer/examples/Right.svelte (1)
23-23
: Consistent implementation of dismissable context pattern.The removal of the inline click handler maintains the architectural consistency across drawer examples while preserving functionality through the new context-based dismissal system.
static/llm/forms/timepicker.md (1)
496-496
: Documentation updated to reflect dismissable context implementation.The removal of the inline
onclick
handler in the documentation example ensures consistency with the new dismissable context pattern implemented in the actual components.src/routes/api-check/components/drawer/examples/Navigation.svelte (1)
14-14
: Final piece of consistent dismissable context implementation.The removal of the explicit
onclick
handler completes the architectural refactor across all drawer examples, ensuring uniform dismissal behavior through the new context mechanism.src/routes/api-check/components/drawer/examples/Scrolling.svelte (1)
16-16
: Drawer close functionality backed by dismissable contextThe
Drawer
component already importscreateDismissableContext
and invokes it with its internalclose
handler (around line 40 insrc/lib/drawer/Drawer.svelte
). This ensures the standalone<CloseButton/>
(without an inlineonclick
) will correctly trigger the drawer’s close action via context. No further changes are needed here.src/routes/api-check/components/drawer/examples/DisablingOutside.svelte (1)
18-18
: LGTM! Consistent with dismissable context pattern.The removal of the inline
onclick
handler is consistent with the new dismissable context approach. This standardizes dismissal behavior across drawer components.src/routes/docs/forms/toggle.md (1)
70-70
: LGTM! Improved API design with unified classes prop.The change from
spanClass={customSize}
toclasses={{ span: customSize }}
represents a better API design that consolidates styling props into a unified object structure. This is more scalable and consistent across components.src/routes/docs/forms/input-field.md (1)
78-78
: LGTM! Consistent with the unified classes API pattern.The update from
divClass
toclasses={{ div: ... }}
is consistent with the broader API improvement across form components. This unified approach to styling props enhances maintainability and consistency.src/lib/forms/search/Search.svelte (2)
6-6
: LGTM! Proper implementation of dismissable context.The import and usage of
createDismissableContext
correctly establishes the dismissal mechanism for the search component.Also applies to: 25-25
41-41
: CloseButton context consumption verifiedThe
CloseButton.svelte
component now correctly imports and callsuseDismiss()
(see line 5:import { useDismiss }…
; line 11:const context = useDismiss();
), so it will invoke the dismissable context’sclearAll
handler as intended. No further changes are needed.src/lib/forms/textarea/Textarea.svelte (1)
6-6
: LGTM! Clean implementation of dismissable context pattern.The changes correctly implement the new dismissable context approach:
- Properly imports and creates the dismissable context with the existing
clearAll
function- Removes the explicit
onclick
handler fromCloseButton
, delegating dismissal to the context mechanism- Maintains all existing functionality while standardizing dismissal behavior
Also applies to: 41-41, 70-70
src/lib/forms/fileupload/Fileupload.svelte (1)
6-6
: LGTM! Consistent implementation of dismissable context.The changes follow the established pattern correctly:
- Adds the dismissable context import and creates context with
clearAll
function- Removes direct
onclick
handler fromCloseButton
- Preserves all file clearing functionality while adopting the standardized dismissal mechanism
Also applies to: 25-25, 31-31
src/routes/api-check/components/drawer/examples/Contact.svelte (1)
16-16
: LGTM! Drawer dismissal now handled by parent component context.The removal of the explicit
onclick
handler is correct as the dismissal behavior is now managed by the parentDrawer
component through the dismissable context mechanism. This simplifies the example code and demonstrates the new standardized approach.src/lib/forms/floating-label/FloatingLabelInput.svelte (1)
7-7
: LGTM! Proper implementation with complex clear logic.The dismissable context implementation is correct:
- Properly imports and creates context with the existing
clearAll
function- Removes explicit
onclick
handler fromCloseButton
- The complex
clearAll
function (handling suggestions, focus management, and callbacks) integrates well with the dismissable context patternAlso applies to: 139-139, 149-149
src/lib/forms/select/MultiSelect.svelte (1)
66-76
: No MouseEvent issues withclearAll
in MultiSelect.svelteThe
clearAll
callback will always receive aMouseEvent
because the only consumer of the dismissable context in this component isCloseButton
, whose click handler explicitly forwards the original event intocontext.dismiss(event)
. No changes are needed.src/lib/forms/select/Select.svelte (3)
6-6
: LGTM - Clean integration of dismissable context.The import follows the established pattern for the dismissable utility module.
34-34
: Excellent implementation of dismissable context.The integration properly leverages the existing
clearAll
function, maintaining backward compatibility while adopting the new standardized dismissal pattern. This eliminates the need for inline click handlers on the CloseButton.
54-54
: Good removal of direct onclick handler.The CloseButton now properly delegates dismissal behavior to the dismissable context, which is cleaner and more maintainable than inline handlers.
src/lib/forms/input-field/Input.svelte (3)
7-7
: LGTM - Consistent dismissable context import.The import follows the established pattern across form components.
60-60
: Well-implemented dismissable context integration.The
clearAll
function is properly integrated with the dismissable context, maintaining the existing sophisticated input clearing logic while adopting the standardized dismissal pattern.
260-260
: Clean removal of inline click handler.The CloseButton now properly uses the dismissable context instead of direct onclick handlers, improving maintainability.
src/routes/docs/components/toast.md (2)
134-134
: Good documentation update for dismissable prop.The change to
dismissable={false}
properly reflects the new dismissable context pattern where dismissal behavior is controlled via the dismissable prop rather than manual onclick handlers.
289-289
: Proper documentation of classes prop pattern.The transition from
contentClass
toclasses={{ content: "..." }}
correctly documents the new standardized classes object pattern, which provides better organization and consistency across components.src/routes/docs/forms/radio.md (1)
84-84
: Excellent consistent documentation updates.The systematic transition from
labelClass
toclasses={{ label: "..." }}
properly documents the new classes object pattern across all Radio component examples. This maintains consistency with the broader API standardization effort while preserving all functionality.Also applies to: 128-128, 131-131, 150-153, 168-171
src/lib/drawer/Drawer.svelte (4)
8-8
: LGTM - Clean import of dismissable context utility.Follows the established pattern for adopting the dismissable context mechanism.
10-10
: Good modernization of the component API.The transition from
closeDrawer
callback prop toonclose
event handler prop provides better event-driven control and follows modern Svelte patterns.
34-40
: Excellent implementation of event-driven dismissal.The new
close
function properly:
- Dispatches a cancelable "close" event for external control
- Only sets
hidden = true
if the event isn't prevented- Integrates with the dismissable context for standardized behavior
This provides much better control flow compared to direct callback invocation.
46-47
: Well-integrated event handling updates.The backdrop properly binds the element reference and attaches the
onclose
event handler, whiletrapFocus
correctly uses the newclose
function for escape key handling.src/lib/toast/Toast.svelte (6)
9-9
: LGTM: Correct import for dismissable context.The import of
createDismissableContext
follows the new dismissable pattern described in the PR objectives.
21-26
: LGTM: Good backward compatibility approach for styling.The styling logic correctly prioritizes the new
classes
prop structure while maintaining backward compatibility with legacyiconClass
andcontentClass
props.
32-32
: LGTM: Correct ref binding for event dispatching.The ref variable is properly typed and will enable event dispatching from the root element in the _close function.
40-40
: LGTM: Correct dismissable context creation.The call to
createDismissableContext
follows the exact pattern described in the PR objectives, providing the _close function as the dismissal handler.
44-44
: LGTM: Well-integrated root element enhancements.The addition of
bind:this={ref}
and{onclose}
properly enables event dispatching and external close event handling, working seamlessly with the dismissable context pattern.
56-56
: LGTM: Perfect demonstration of dismissable context pattern.The CloseButton now relies on the dismissable context instead of explicit click handlers, exactly as described in the PR objectives. The styling also correctly uses the new
classes?.close
pattern.
This is now ready apart of |
📑 Description
This is another approach to the
CloseButton
.It uses the
setContext/getContext
. It requires to adding one line to alldissmisable
components.If you want to handle the
CloseButton
yourself (customize, relocate, add features), you setdismissable={false}
and addCloseButton
manually.This PR modifies only
Badge
for starting the discussion.Status
✅ Checks
ℹ Additional Information
Summary by CodeRabbit