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 remove redundant code #35157

Merged
merged 10 commits into from
Dec 1, 2021
Merged

Dropdown remove redundant code #35157

merged 10 commits into from
Dec 1, 2021

Conversation

GeoSot
Copy link
Member

@GeoSot GeoSot commented Oct 10, 2021

This MR,

  • merges the data-bs-display="static" & isNavBar case handling
  • refactors the dataApiKeydownHandler simplifying the checks, and shows that a code block was useless
  • it also removes a static method that was called once

NOTE for reviewers:

Better review it, commit by commit. It will help you with the proper message and will guide you with sanity to follow the logic

@GeoSot GeoSot added this to In progress in v5.2.0 via automation Oct 10, 2021
@XhmikosR XhmikosR moved this from In progress to Review in progress in v5.2.0 Oct 11, 2021
@@ -254,13 +251,7 @@ class Dropdown extends BaseComponent {
}

const popperConfig = this._getPopperConfig()
const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdo @rohit2sharma95: we need your input on this. There must some reason this was added?

Copy link
Collaborator

@rohit2sharma95 rohit2sharma95 Oct 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It identifies the behavior of the dropdown is static or not. Since the dropdown may be static without having the display: 'static' in the config or in the data attributes (Via the popper modifiers)

This flag variable is then used to add a data attribute which helps in the CSS to place the dropdown menu properly 🙂

See #32986 for the reference

@@ -254,13 +251,7 @@ class Dropdown extends BaseComponent {
}

const popperConfig = this._getPopperConfig()
const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false)
Copy link
Collaborator

@rohit2sharma95 rohit2sharma95 Oct 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It identifies the behavior of the dropdown is static or not. Since the dropdown may be static without having the display: 'static' in the config or in the data attributes (Via the popper modifiers)

This flag variable is then used to add a data attribute which helps in the CSS to place the dropdown menu properly 🙂

See #32986 for the reference

// Totally disable Popper for Dropdowns in Navbar
if (this._inNavbar) {
if (this._inNavbar || this._config.display === 'static') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this will fully disable the Popper for the dropdown (with display: 'static' in the config) and will not create a popper instance for the dropdown 😨

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohit2sharma95

If I have understand right, 'static' option as you say too, is given to "help the CSS to place the dropdown menu properly "
So in other words to 'disable' popper calculate things, right?

Our used css selector is [data-bs-popper]. So we do not miss something

Example:
https://deploy-preview-35157--twbs-bootstrap.netlify.app/docs/5.1/components/dropdowns/#responsive-alignment

Although, I am not sure if we still need popper initiated for another reason, as it seems useless.
Or we maybe could enable popper static to navbar too. These are too different approaches, but with the same result.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True @GeoSot, the static dropdown is not placed by the Popper though but removing the whole popper instance for the static dropdown may be a breaking change IMO 🙂

/CC @XhmikosR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohit2sharma95 kept the popper instance as you suggested 😃

v5.2.0 automation moved this from Review in progress to Reviewer approved Dec 1, 2021
@XhmikosR XhmikosR marked this pull request as ready for review December 1, 2021 15:10
@XhmikosR XhmikosR requested a review from a team as a code owner December 1, 2021 15:10
@XhmikosR XhmikosR merged commit a594536 into main Dec 1, 2021
@XhmikosR XhmikosR deleted the gs/dropdown-clean-up branch December 1, 2021 15:10
v5.2.0 automation moved this from Reviewer approved to Done Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v5.2.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants