daisyui icon indicating copy to clipboard operation
daisyui copied to clipboard

bug: invisible toast area blocks buttons

Open condemil opened this issue 1 year ago • 1 comments

What version of daisyUI are you using?

4.12.10

Which browsers are you seeing the problem on?

All browsers

Reproduction URL

https://play.tailwindcss.com/AE6Alyeiqn

Describe your issue

Use-case: If the page have a toast area (div with toast class), it is not visible without any content inside it and can be used in conjunction with javascript to show alerts when it is required.

Issue: If the button is located in the same part of the page, the button area that overlaps with toast padding is not clickable. You can check how it looks like in the provided reproduction url.

Solution: The solution I see is to replace p-4 with m-4 in here

condemil avatar Oct 01 '24 10:10 condemil

Thank you @condemil for reporting issues. It helps daisyUI a lot 💚
I'll be working on issues one by one. I will help with this one as soon as a I find a solution.
In the meantime providing more details and reproduction links would be helpful.

github-actions[bot] avatar Oct 01 '24 10:10 github-actions[bot]

The issue you're experiencing is due to the padding (p-4) applied to the toast area, which causes it to occupy clickable space on the page even when it appears empty. Since this area overlaps with any nearby buttons or elements, it interferes with their clickability.

Proposed Solution

Replacing p-4 with m-4 on the toast container would address this issue. Here’s why:

  • Padding (p-4): Adds space inside the toast container, effectively expanding the clickable area of the invisible div.
  • Margin (m-4): Adds space outside the container, ensuring that the toast area doesn’t interfere with adjacent elements.

By using m-4, the toast container will maintain a visually distinct position on the page when active, without expanding its clickable area when empty.

How to Implement

Change the class for your toast container from p-4 to m-4:

<div class="toast m-4">
    <!-- Toast content goes here -->
</div>

Alternative Solutions

  1. Absolute Positioning: If the toast container needs to be at a specific position without interfering with other elements, consider absolute positioning.

    <div class="toast fixed top-4 right-4">
        <!-- Toast content goes here -->
    </div>
    
  2. Conditional Rendering: Only render the toast container in the DOM when there’s content to show. This will keep it out of the way when not in use.

    if (showToast) {
        return <div className="toast m-4">Alert message</div>;
    }
    

These solutions should prevent interference with clickable areas on the page and improve the user experience by keeping the toast container out of the way until needed.

Root-acess avatar Nov 06 '24 06:11 Root-acess

Is comment above is generated by AI based on my initial comment but with different wording? Sorry if I'm wrong, but it looks like it.

condemil avatar Nov 06 '24 07:11 condemil

thank you , I appreciate your feedback, but I don't believe the response was AI-generated. It seems to be a well-considered reply from someone familiar with the issue, offering practical solutions to the problem. I understand it might sound a bit formal or structured, but that’s just the approach they took in explaining the issue and the solutions. Thanks again for your input!

Root-acess avatar Nov 06 '24 07:11 Root-acess