Skip to content
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

Incorrect position if tailwind set important true #15

Open
erwinyusrizal opened this issue Mar 16, 2023 · 2 comments
Open

Incorrect position if tailwind set important true #15

erwinyusrizal opened this issue Mar 16, 2023 · 2 comments

Comments

@erwinyusrizal
Copy link

Hi, If I set tailwind config important: true the datepicker dropdown open to the default position top-0 left-0 since it is important, the dynamic position ignored

Screenshot from 2023-03-16 20-56-20

I think you need to get rid the top-0 left-0 default class from the datepicker dropdown since the initial position already handled by JS

Screenshot from 2023-03-16 20-57-54

Thanks

@erwinyusrizal erwinyusrizal changed the title Incorrect position if taiilwind set important true Incorrect position if tailwind set important true Mar 16, 2023
@timotiushadi
Copy link

im having this problem too. Is this already fixed? or any alternative way to do the correct ways?

@lanius412
Copy link

The code below is not the fix but my temporary solution. (datepicker.js)

From:

elementClass === 'dropdown' ? element.classList.add('dropdown', 'absolute', 'top-0', 'left-0', 'z-50', 'pt-2') : null;

To:

elementClass === 'dropdown' ? element.classList.add('dropdown', 'absolute', 'z-50', 'pt-2') : null;

In addition, when clicking or focusing, you can scroll to the datepicker with the following code.

function onFocus(datepicker) {
  if (datepicker.config.showOnFocus && !datepicker._showing) {
    datepicker.show();
     // ↓↓↓
    datepicker.picker.element.scrollIntoView({  
      behavior: 'smooth'  
    });
  }
}
function onClickInput(datepicker, ev) {
  const el = ev.target;
  if (!el._clicking) {
    return;
  }
  clearTimeout(el._clicking);
  delete el._clicking;

  if (el._active) {
    datepicker.enterEditMode();
  }
  delete el._active;

  if (datepicker.config.showOnClick) {
    datepicker.show();
    // ↓↓↓
    datepicker.picker.element.scrollIntoView({  
      behavior: 'smooth'  
    });
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants