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

Dropdown toggle caret doesn't respect left/right direction #1863

Open
silhusk opened this issue Feb 6, 2023 · 6 comments
Open

Dropdown toggle caret doesn't respect left/right direction #1863

silhusk opened this issue Feb 6, 2023 · 6 comments

Comments

@silhusk
Copy link
Contributor

silhusk commented Feb 6, 2023

The caret in the dropdown toggle is shown pointing downward also when the @direction is left or right. The class being added results in dropleft, resp. dropright. Whereas, for BS5 they should be dropstart, resp. dropend (they respect RTL).

return this.direction !== 'down' ? `btn-group drop${this.direction}` : 'btn-group';

return `drop${this.direction}`;

$ npx ember bootstrap:info
Npm packages:
ember-bootstrap: ^6.0.0-1 -> 6.0.0-1
ember-cli: ^4.10.0 -> 4.10.0
bootstrap: ^5.1.1 -> 5.2.3
bootstrap-sass: n/a
ember-cli-sass: ^11.0.1 -> 11.0.1
ember-cli-less: n/a
Bower packages:
bootstrap: n/a
bootstrap-sass: n/a
ember-bootstrap configuration:
bootstrapVersion: 5
importBootstrapFont: false
importBootstrapCSS: false
@jelhan
Copy link
Contributor

jelhan commented Feb 6, 2023

Is it working if using @direction="start" and @direction="end"? I also recently wondered if left and right values are still correct for those arguments if using BS5 when reviewing the Glint types (#1861). Maybe it is just an error in API docs?

@silhusk
Copy link
Contributor Author

silhusk commented Feb 6, 2023

By using @direction="start" it does add the correct class dropstart , but then popper is given a wrong argument and the menu opens down (the default).

} else if (direction === 'left') {

@jelhan
Copy link
Contributor

jelhan commented Feb 6, 2023

Thanks for investigating! I wasn't aware that it's also used with Popper. Do you know how that misalignment on namings is solved in Bootstrap itself?

@silhusk
Copy link
Contributor Author

silhusk commented Feb 7, 2023

Relevant snippets taken from https://github.com/twbs/bootstrap/blob/cbc4e3a4098506315c32346b194e9e1a4d7db091/js/src/dropdown.js

// Line 50
const CLASS_NAME_DROPEND = 'dropend'
const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start'

// Line 248
_getPlacement() {
  const parentDropdown = this._parent

  if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
    return PLACEMENT_RIGHT
  }

  if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
    return PLACEMENT_LEFT
  }
  ...
}

// Line 295
_getPopperConfig() {
  const defaultBsPopperConfig = {
    placement: this._getPlacement(),
    ...
  }
  ...
}

@jelhan
Copy link
Contributor

jelhan commented Feb 8, 2023

Thanks a lot for looking up that information!

I feel we should do the following:

  1. Fix @direction="left and @direction="right" to apply correct classes for Bootstrap 5 (dropstart, dropend). That would fix the immediate bug.
  2. Rename left and right to start and end not only in this case but for all arguments. We may want to keep the old names as deprecated alias for now to ease migration.

PR for the short-term fix listed as first step is very welcome. Do you have time working on it?

I would like giving @simonihmig the chance to raid concerns with second step, the remaining of argument values, before picking it up.

@simonihmig
Copy link
Contributor

Yeah, I wouldn't mind doing 2., if anyone has the time for that!? 🙃

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

No branches or pull requests

3 participants