Resolve inconsistent behavior in 'show' and 'hide' methods#41301
Conversation
Ensure that the 'show' method will only cause the element to be shown, and that the 'hide' method will only cause the element to be hidden, regardless of the current state
Member
|
Thanks for your contribution, @D07N37! We haven't reviewed the content yet, but could you please add some unit tests to this PR? Ideally, they should fail on the |
Author
|
Looking through the unit tests, this._isShown is actually a method so the original edits do not work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently the
_isShownproperty is being checked in the 'show' and 'hide' methods, but the_isShownproperty is never changed, causing it to stay false no matter the component's state. This behavior is inconsistent with the behavior of other components, and can cause undesired behavior when the same method is called multiple times in succession.This PR introduces code in the constructor to set the
_isShownproperty based on the current classes of the component (in accordance with the documentation), and to update the_isShownproperty in the 'show' and 'hide' methods.Motivation & Context
Currently the 'show' and 'hide' methods of the collapse component act like its 'toggle' method, ignoring whether the component is actually shown or hidden.
Type of changes
Checklist
npm run lint)