Skip to content

Commit

Permalink
fix(toc): tweak media query for sidebar at lg (#12133)
Browse files Browse the repository at this point in the history
### Related Ticket(s)

[ADCMS-6990](https://jsw.ibm.com/browse/ADCMS-6990)

### Description

Adjusts the media query logic in the TOC component to line up with the Sass for the same. This fixes an issue where before, right on the lg breakpoint, the TOC was broken and stuck showing mostly mobile styles instead of desktop ones.

### Changelog

**Changed**

- TOC wlll now maintain the desktop layout for the lg breakpoint and above.

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "test: e2e": Codesandbox examples and e2e integration tests -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
  • Loading branch information
m4olivei authored Nov 29, 2024
1 parent f82fdea commit b434156
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function findLastIndex<T>(
@customElement(`${c4dPrefix}-table-of-contents`)
class C4DTableOfContents extends MediaQueryMixin(
HostListenerMixin(StableSelectorMixin(LitElement)),
{ [MQBreakpoints.LG]: MQDirs.MAX }
{ [MQBreakpoints.LG]: MQDirs.MIN }
) {
/**
* Defines TOC type, "" for default, `horizontal` for horizontal variant.
Expand Down Expand Up @@ -157,7 +157,7 @@ class C4DTableOfContents extends MediaQueryMixin(
* Whether we're viewing smaller or larger window.
*/
@state()
_isMobile = this.carbonBreakpoints.lg.matches;
_isMobile = !this.carbonBreakpoints.lg.matches;

/**
* The target elements matching `[name]` harvested from the document.
Expand Down Expand Up @@ -625,8 +625,8 @@ class C4DTableOfContents extends MediaQueryMixin(
}
}

mediaQueryCallbackMaxLG() {
this._isMobile = this.carbonBreakpoints.lg.matches;
mediaQueryCallbackLG() {
this._isMobile = !this.carbonBreakpoints.lg.matches;
}

/**
Expand Down

0 comments on commit b434156

Please sign in to comment.