Skip to content

fix: make setItems method on accordion protected for extensibility of base class#35898

Open
chrisdholt wants to merge 1 commit intomicrosoft:masterfrom
chrisdholt:users/chhol/make-accordion-set-items-protected
Open

fix: make setItems method on accordion protected for extensibility of base class#35898
chrisdholt wants to merge 1 commit intomicrosoft:masterfrom
chrisdholt:users/chhol/make-accordion-set-items-protected

Conversation

@chrisdholt
Copy link
Member

Previous Behavior

Private methods prevent extensibility of the base class.

New Behavior

setItems method updated to support extensibility by changing from private to protected

Related Issue(s)

  • Fixes #

@chrisdholt chrisdholt requested a review from a team as a code owner March 24, 2026 21:31
@github-actions
Copy link

📊 Bundle size report

✅ No changes found

@github-actions
Copy link

Pull request demo site: URL

@@ -0,0 +1,7 @@
{

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-web-components/Avatar 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Avatar. - Dark Mode.normal.chromium_1.png 298 Changed
vr-tests-web-components/Badge 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Badge. - Dark Mode.normal.chromium.png 443 Changed
vr-tests-web-components/MenuList 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/MenuList. - RTL.2nd selected.chromium.png 17 Changed
vr-tests-web-components/RadioGroup 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/RadioGroup. - Dark Mode.2nd selected.chromium_3.png 119 Changed

* @returns {void}
*/
private setItems = (): void => {
protected setItems = (): void => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally all of the methods that belong to the Accordion would be class methods instead of instance properties:

Suggested change
protected setItems = (): void => {
protected setItems(): void {

(You'll also have to remove the semicolon on line 131)

* Checks if the accordion is in single expand mode
* @returns {boolean}
*/
private isSingleExpandMode(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
protected isSingleExpandMode(): boolean {

* @param expandedItem The item to expand in single expand mode
* @returns {void}
*/
private setSingleExpandMode(expandedItem: Element): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
protected setSingleExpandMode(expandedItem: Element): void {

* Removes event listeners from the previous accordion items
* @param oldValue An array of the previous accordion items
*/
private removeItemListeners = (oldValue: any): void => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
protected removeItemListeners(oldValue: any): void {

The type for oldValue should probably also be something better than any

* @param evt Click event
* @returns
*/
private expandedChangedHandler: EventListener = (evt: Event): void => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public expandedChangedHandler: EventListener = (evt: Event): void => {

Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually one of the specific things that should be addressed beyond marking the methods protected/public: why are the event handlers being added and removed to the child accordion items, by the accordion itself? It should either use one event on the accordion that identifies which accordion item was clicked, or the accordion items themselves should handle their own click events.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants