Skip to content

Commit

Permalink
Merge pull request #273 from StampyAI/bugfixes
Browse files Browse the repository at this point in the history
update react-auto-height library
  • Loading branch information
Aprillion authored Jul 6, 2023
2 parents f966518 + 50c5fa5 commit e0cb46a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 40 deletions.
23 changes: 0 additions & 23 deletions app/hooks/useRerenderOnResize.ts

This file was deleted.

13 changes: 4 additions & 9 deletions app/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import {loadInitialQuestions, QuestionState} from '~/server-utils/stampy'
import {TOP} from '~/hooks/stateModifiers'
import useQuestionStateInUrl from '~/hooks/useQuestionStateInUrl'
import useRerenderOnResize from '~/hooks/useRerenderOnResize'
import useDraggable from '~/hooks/useDraggable'
import {getStateEntries} from '~/hooks/stateModifiers'
import Search from '~/components/search'
Expand Down Expand Up @@ -119,21 +118,20 @@ export default function App() {
glossary,
} = useQuestionStateInUrl(minLogo, initialQuestions)

useRerenderOnResize() // recalculate AutoHeight

const openQuestionTitles = questions
.filter(({questionState}) => questionState === '_')
.map(({title}) => title)

const showMore = (el: HTMLElement, toggle = false) => {
const container = el.closest('.react-auto-height') as HTMLElement
const button = container.getElementsByClassName('see-more')[0]
const button = el.closest('.answer')?.querySelector('.see-more')
if (toggle) {
button?.classList.toggle('visible')
} else {
button?.classList.add('visible')
}
container.style.removeProperty('height')
// The AutoHeight component doesn't notice when a random <div> changes CSS class,
// so manually triggering toggle event (as if this was a <details> element).
dispatchEvent(new Event('toggle'))
}

const handleSpecialLinks = (e: MouseEvent) => {
Expand All @@ -145,9 +143,6 @@ export default function App() {
)
return

// The AutoHeight component doesn't notice when a HTML details is opened.
// Manually removing the height from the style fixes this, but can potentially
// break something else...
if (el.classList.contains('see-more')) {
showMore(el, true)
e.preventDefault()
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"markdown-it-footnote": "^3.0.3",
"node-html-parser": "^5.4.2",
"react": "^17.0.2",
"react-auto-height": "^1.1.6",
"react-auto-height": "^1.2.0",
"react-dom": "^17.0.2",
"remix": "^1.13.0"
},
Expand Down

0 comments on commit e0cb46a

Please sign in to comment.