@cypress-design/react-docmenu 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,5 +2,5 @@ $ yarn build:module && yarn build:types
2
2
  $ rollup -c ./rollup.config.mjs
3
3
  
4
4
  ./index.ts → ./dist/index.umd.js, ./dist/index.es.mjs...
5
- created ./dist/index.umd.js, ./dist/index.es.mjs in 17.8s
5
+ created ./dist/index.umd.js, ./dist/index.es.mjs in 16.5s
6
6
  $ tsc --project ./tsconfig.build.json
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @cypress-design/react-docmenu
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ad32042`](https://github.com/cypress-io/cypress-design/commit/ad3204289730de696c9728b1343e06ce68382561) Thanks [@elevatebart](https://github.com/elevatebart)! - only skip scrolling if both dimension are in view
8
+
3
9
  ## 0.7.0
4
10
 
5
11
  ### Minor Changes
@@ -150,7 +150,7 @@ describe('<DocMenu/>', () => {
150
150
  const SUT = () => {
151
151
  const [pathState, setPathState] = React.useState<string>('/foo')
152
152
  return (
153
- <>
153
+ <div className="p-4">
154
154
  <button
155
155
  onClick={() => setPathState('/faa6')}
156
156
  className="p-2 m-2 rounded bg-gray-100 border border-gray-300"
@@ -171,13 +171,14 @@ describe('<DocMenu/>', () => {
171
171
  activePath={pathState}
172
172
  collapsible
173
173
  />
174
- </>
174
+ </div>
175
175
  )
176
176
  }
177
177
  mount(<SUT />)
178
178
 
179
179
  cy.findByText('Code').click()
180
180
  cy.contains('Set path to').click()
181
+ cy.wait(200)
181
182
  cy.contains('Quisquam, quos').then(($el) => {
182
183
  const windowInnerHeight = Cypress.config(`viewportHeight`)
183
184
 
package/_DocLink.tsx CHANGED
@@ -57,24 +57,28 @@ export const DocLink = React.forwardRef<DocLinkForward, DocLinkProps>(
57
57
  React.useEffect(setActiveMarkerPosition, [onActive, active])
58
58
 
59
59
  React.useEffect(() => {
60
- if (active && activeLIRef.current) {
61
- // if active check if the item is visible in the
62
- // viewport and scrollIntoView if not
63
- const rect = activeLIRef.current.getBoundingClientRect()
64
-
65
- if (rect.top > 0 && rect.bottom < window.innerHeight) {
66
- return
67
- }
68
-
69
- if (rect.left > 0 && rect.right < window.innerWidth) {
70
- return
60
+ // if active check if the item is visible in the
61
+ // viewport and scrollIntoView if not
62
+ setTimeout(() => {
63
+ // give it time tp render and expand
64
+ if (active && activeLIRef.current) {
65
+ const rect = activeLIRef.current.getBoundingClientRect()
66
+
67
+ if (
68
+ rect.top > 0 &&
69
+ rect.bottom < window.innerHeight &&
70
+ rect.left > 0 &&
71
+ rect.right < window.innerWidth
72
+ ) {
73
+ return
74
+ }
75
+
76
+ activeLIRef.current.scrollIntoView({
77
+ block: 'nearest',
78
+ inline: 'nearest',
79
+ })
71
80
  }
72
-
73
- activeLIRef.current.scrollIntoView({
74
- block: 'nearest',
75
- inline: 'nearest',
76
- })
77
- }
81
+ }, 200)
78
82
  }, [active])
79
83
 
80
84
  React.useImperativeHandle(ref, () => ({
@@ -82,7 +86,7 @@ export const DocLink = React.forwardRef<DocLinkForward, DocLinkProps>(
82
86
  }))
83
87
 
84
88
  return (
85
- <li ref={activeLIRef} className="list-none p-0">
89
+ <li ref={activeLIRef} className="list-none p-0 scroll-my-10">
86
90
  <LinkComponent
87
91
  {...itemRest}
88
92
  className={clsx('group relative block w-full pl-[24px]', {
@@ -1 +1 @@
1
- {"version":3,"file":"_DocLink.d.ts","sourceRoot":"./","sources":["_DocLink.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAE/D,MAAM,WAAW,OAAO;IACtB,iBAAiB,EAAE,CAAC,cAAc,EAAE,OAAO,KAAK,IAAI,CAAA;IACpD,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IACl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;CAC1B,CAAC,CAAA;AAEF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,OAAO,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACzD,aAAa,EAAE,iBAAiB,CAAA;CACjC;AAED,MAAM,WAAW,cAAc;IAC7B,uBAAuB,EAAE,MAAM,IAAI,CAAA;CACpC;AAED,eAAO,MAAM,OAAO,qFAwFnB,CAAA"}
package/dist/index.es.mjs CHANGED
@@ -181,26 +181,29 @@ var DocLink = React.forwardRef(function (_a, ref) {
181
181
  // send the top position to the parent
182
182
  React.useEffect(setActiveMarkerPosition, [onActive, active]);
183
183
  React.useEffect(function () {
184
- if (active && activeLIRef.current) {
185
- // if active check if the item is visible in the
186
- // viewport and scrollIntoView if not
187
- var rect = activeLIRef.current.getBoundingClientRect();
188
- if (rect.top > 0 && rect.bottom < window.innerHeight) {
189
- return;
190
- }
191
- if (rect.left > 0 && rect.right < window.innerWidth) {
192
- return;
184
+ // if active check if the item is visible in the
185
+ // viewport and scrollIntoView if not
186
+ setTimeout(function () {
187
+ // give it time tp render and expand
188
+ if (active && activeLIRef.current) {
189
+ var rect = activeLIRef.current.getBoundingClientRect();
190
+ if (rect.top > 0 &&
191
+ rect.bottom < window.innerHeight &&
192
+ rect.left > 0 &&
193
+ rect.right < window.innerWidth) {
194
+ return;
195
+ }
196
+ activeLIRef.current.scrollIntoView({
197
+ block: 'nearest',
198
+ inline: 'nearest',
199
+ });
193
200
  }
194
- activeLIRef.current.scrollIntoView({
195
- block: 'nearest',
196
- inline: 'nearest',
197
- });
198
- }
201
+ }, 200);
199
202
  }, [active]);
200
203
  React.useImperativeHandle(ref, function () { return ({
201
204
  setActiveMarkerPosition: setActiveMarkerPosition,
202
205
  }); });
203
- return (React.createElement("li", { ref: activeLIRef, className: "list-none p-0" },
206
+ return (React.createElement("li", { ref: activeLIRef, className: "list-none p-0 scroll-my-10" },
204
207
  React.createElement(LinkComponent, __assign$1({}, itemRest, { className: clsx('group relative block w-full pl-[24px]', {
205
208
  'text-indigo-500 dark:text-indigo-400': active,
206
209
  'text-gray-700 dark:text-gray-500': !active,
@@ -423,4 +426,4 @@ var DocMenu = function (_a) {
423
426
  export { DocMenu as default };
424
427
  //# sourceMappingURL=index.es.mjs.map
425
428
 
426
- /* <wind-keep class="container relative absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 dark:bg-indigo-400 ml-[6.5px] mt-[4px] transition ease-in-out text-indigo-500 dark:text-indigo-400 text-gray-900 dark:text-gray-100 text-gray-800 dark:text-gray-200 rotate-0 -rotate-90 transition-all grid grid-rows-[0fr] grid-rows-[1fr] overflow-hidden filter list-none p-0 visible block inline w-full pl-[24px] text-gray-700 dark:text-gray-500 py-[8px] text-[16px] leading-[24px] leading-[20px] text-[14px] py-[12px] left-[6.5px] top-[4px] bottom-[4px] z-10 hidden group-hover:block bg-gray-300 text-indigo-400 text-gray-500 bg-indigo-400 left-0 transform transition-transform text-gray-400 dark:text-gray-700 flex py-[10px] items-center text-start font-medium pl-[48px] left-[8px] top-0 w-[1px] h-full bg-gray-100 dark:bg-gray-900"> */
429
+ /* <wind-keep class="container relative absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 dark:bg-indigo-400 ml-[6.5px] mt-[4px] transition ease-in-out text-indigo-500 dark:text-indigo-400 text-gray-900 dark:text-gray-100 text-gray-800 dark:text-gray-200 rotate-0 -rotate-90 transition-all grid grid-rows-[0fr] grid-rows-[1fr] overflow-hidden filter list-none p-0 visible block inline scroll-my-10 w-full pl-[24px] text-gray-700 dark:text-gray-500 py-[8px] text-[16px] leading-[24px] leading-[20px] text-[14px] py-[12px] left-[6.5px] top-[4px] bottom-[4px] z-10 hidden group-hover:block bg-gray-300 text-indigo-400 text-gray-500 bg-indigo-400 left-0 transform transition-transform text-gray-400 dark:text-gray-700 flex py-[10px] items-center text-start font-medium pl-[48px] left-[8px] top-0 w-[1px] h-full bg-gray-100 dark:bg-gray-900"> */