Skip to content

Conversation

@wuda-io
Copy link
Member

@wuda-io wuda-io commented Dec 8, 2020

…Query. Especially the function getClosestAncestor(). See issue #43

Proposed changes

Fixes a Bug for operation. For more info see the issue.

Screenshots (if appropriate) or codepen:

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to change).

Checklist:

  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

…Query. Especially the function getClosestAncestor(). See issue #43
@Smankusors Smankusors linked an issue Dec 10, 2020 that may be closed by this pull request
Comment on lines +532 to +548
/**
* Get closest ancestor that satisfies the condition
* @param {Element} el Element to find ancestors on
* @param {Function} condition Function that given an ancestor element returns true or false
* @returns {Element} Return closest ancestor or null if none satisfies the condition
*/
const getClosestAncestor = function(el, condition) {
let ancestor = el.parentNode;
while (ancestor !== null && !$(ancestor).is(document)) {
if (condition(ancestor)) {
return ancestor;
}
ancestor = ancestor.parentNode;
}
return null;
};

Copy link
Member

Choose a reason for hiding this comment

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

is this PR only moves getClosestAnchor from global to dropdown? And deletes elementOrParentIsFixed? I don't see any other differences here... And I'm not sure how this fixes the linked issue...?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes exactly!
getClosestAnchor
Because the function uses the $ operator, which is not accessible in the global.js File => This caused the Error.
So I searched where the function is used and it is only used by dropdown.js so I moved it there. This solves the Bug.
elementOrParentIsFixed
I saw that this function also uses the $ operatorm so I also search where the function is called. And it is never beeing called.
So I removed the function.
You can test it via the Select-Dropdown. Best regards and thanks for your time bro!

Choose a reason for hiding this comment

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

So elementOrParentIsFixed was never documented and was some internal leftover?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes @DanielRuf I dont know why this function is there. I searched the whole repo and it wasnt used anywhere, so I removed it.

Copy link

@DanielRuf DanielRuf left a comment

Choose a reason for hiding this comment

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

I think we should mark it as internal by prepending _ to the function name.

* @param {Function} condition Function that given an ancestor element returns true or false
* @returns {Element} Return closest ancestor or null if none satisfies the condition
*/
const getClosestAncestor = function(el, condition) {

Choose a reason for hiding this comment

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

Wait, is this a function in a function? Why not use _placeDropdown then?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, because it is used inside the function only... I dont know how to change the code in an existing PR. Can this be done via the WebInterface?

Choose a reason for hiding this comment

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

You can push additional commits on the same branch in your repo or use https://github.com/materializecss/materialize/pull/57/files

grafik

@DanielRuf
Copy link

Bump =)

What is the current state of this PR, also regarding the review comments?

@DanielRuf
Copy link

Let's merge this =)

@DanielRuf DanielRuf merged commit 4ef3946 into materializecss:v1-dev Feb 13, 2021
@DanielRuf
Copy link

You should have received an invitation to join @materializecss as member and collaborator for https://materializecss/materialize.

@Smankusors Smankusors added the bug Something isn't working label Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working component: dropdown

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select does not work without jQuery

3 participants