Giter Club home page Giter Club logo

Comments (14)

brojor avatar brojor commented on May 24, 2024 1

we can add a backdrop to every component that is popup like and when the user clicks outside of the component top most component will get closed.

Yeah, that sounds good.

This is a tiny experiment I did and I think it might look promising and allows Infinite nesting without worry like other frameworks.

That's a cool idea and I like it. I can imagine how it would be nicely layered.

from anu.

IcetCode avatar IcetCode commented on May 24, 2024 1

I found a new way and wanted to validate it with you:

I will use provide & inject to handle js z-index correctly (just for rendering, we still need to handle drawer close on click of select option).

In parent component we will have zIndexModifier:

// get zIndexModifier from parent component
const zIndexModifier = inject('zIndexModifier', 0)

// Increase zIndexModifier by 10 and add current component's zIndex
const zIndex = zIndexModifier + 10 + 6
provide('zIndexModifier', zIndex)

Now on child component like select we will have the same code:

// provide is not needed in select. Hence we can also omit adding 10 to zIndexModifier
const zIndexModifier = inject('zIndexModifier', 0)
const zIndex = zIndexModifier + 4

According to this assuming new z-index for current docs:

6 drawer
5 navbar
4 menu
4 select

Now for the drawer, we will have 16 z-index and for select inside it, we will have (16 + 10 = ) 26 z-index. However, if select isn't inside drawer its z-index will be 14 as normal below drawer πŸ˜‡

Next, when we click on any select option it will close the drawer. For this we will need to assign dynamic id to each drawer and using the .closest we can omit closing the drawer.

This is a tiny experiment I did and I think it might look promising and allows Infinite nesting without worry like other frameworks.

Off to bed. Please let me know your thoughts on this.

Following this approach, I made this PR to fix the problem.

from anu.

jd-solanki avatar jd-solanki commented on May 24, 2024

Maybe we need to use use inline style for z-index based on some strategy. E.g. increase z-index if opened inside drawer.

Do you have any good idea?

from anu.

brojor avatar brojor commented on May 24, 2024

Maybe add some name property to the ADrawer component and in ASelect use closest() method to see if is ASelect inside the ADrawer?

from anu.

jd-solanki avatar jd-solanki commented on May 24, 2024

Looks promising, just have to confirm if this will search in virtual DOM and don't modify/touch the existing DOM.

However, Select & Drawer at the moment are siblings not parent-child.

from anu.

brojor avatar brojor commented on May 24, 2024

Unfortunately, I have no idea how to verify that DOM will not be touched during the search.

I thought Select is a descendant of Drawer and only his options are teleported into the body and thus siblings.

from anu.

jd-solanki avatar jd-solanki commented on May 24, 2024

Yes! Only select's options/dropdown is teleported πŸ’―

from anu.

jd-solanki avatar jd-solanki commented on May 24, 2024

I checked other frameworks and they just give too much z-index to select and it overlaps on the navbar like below:
Screenshot 2022-10-12 at 4 09 12 PM

from anu.

jd-solanki avatar jd-solanki commented on May 24, 2024

Tonight I will check how others doing this and will let you know about the solution.

if you have anything to share please let me know.

from anu.

brojor avatar brojor commented on May 24, 2024

All I can think of now is:

  • set a large z-index
  • conditionally increase the index using in-line style
  • conditionally change the teleport target (which would also solve #45 )

from anu.

jd-solanki avatar jd-solanki commented on May 24, 2024

I found a new way and wanted to validate it with you:

I will use provide & inject to handle js z-index correctly (just for rendering, we still need to handle drawer close on click of select option).

In parent component we will have zIndexModifier:

// get zIndexModifier from parent component
const zIndexModifier = inject('zIndexModifier', 0)

// Increase zIndexModifier by 10 and add current component's zIndex
const zIndex = zIndexModifier + 10 + 6
provide('zIndexModifier', zIndex)

Now on child component like select we will have the same code:

// provide is not needed in select. Hence we can also omit adding 10 to zIndexModifier
const zIndexModifier = inject('zIndexModifier', 0)
const zIndex = zIndexModifier + 4

According to this assuming new z-index for current docs:

6 drawer
5 navbar
4 menu
4 select

Now for the drawer, we will have 16 z-index and for select inside it, we will have (16 + 10 = ) 26 z-index. However, if select isn't inside drawer its z-index will be 14 as normal below drawer πŸ˜‡

Next, when we click on any select option it will close the drawer. For this we will need to assign dynamic id to each drawer and using the .closest we can omit closing the drawer.

This is a tiny experiment I did and I think it might look promising and allows Infinite nesting without worry like other frameworks.

Off to bed. Please let me know your thoughts on this.

from anu.

jd-solanki avatar jd-solanki commented on May 24, 2024

Oh, i forgot .closest cant find sibling.

Have to find another way to prevent closing.

from anu.

jd-solanki avatar jd-solanki commented on May 24, 2024

we can add a backdrop to every component that is popup like and when the user clicks outside of the component top most component will get closed.

E.g. When you open select inside drawer click outside of select will close the select and not drawer as we clicked on backdrop of select. We will remove onclickoutside composable usage.

from anu.

IcetCode avatar IcetCode commented on May 24, 2024

I also created another PR to fix the issue where ADrawer close event would be affected by other components.

from anu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.