Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Mar 18, 2021

Core's counterpart to https://github.com/streamlit/s4t/pull/1034. For Markdown Anchors to work, core and cloud need to notify each other when the browser URL hash changes. This PR

  • Adds a hashchange handler that sends an UPDATE_HASH message to Cloud
  • Listens for UPDATE_HASH messages from Cloud and updates our own hash

@ghost ghost self-requested a review March 18, 2021 19:48
Copy link
Collaborator

@kmcgrady kmcgrady left a comment

Choose a reason for hiding this comment

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

This looks good and probably could benefit from unit tests.

As a side note: I'm concerned about how we inject s4a communication across our system. It's fine in one place, but it's becoming a polluted landscape. Might not want to resolve now, but it might be good to talk about the longer issue in the end.


React.useEffect(() => {
const listener = (): void => {
s4aCommunication.sendMessage({
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if we add the hoc here, we are going to initiate the 'ready' procedure twice, I would just import sendS4AMessage as we need it only for that.

@arraydude
Copy link
Contributor

arraydude commented Mar 26, 2021

This looks good and probably could benefit from unit tests.

As a side note: I'm concerned about how we inject s4a communication across our system. It's fine in one place, but it's becoming a polluted landscape. Might not want to resolve now, but it might be good to talk about the longer issue in the end.

adding to @kmcgrady's comment, We could add the event listener directly into the comm HOC unless there is some constraint that we need it into the ReportView component?

@ghost
Copy link
Author

ghost commented Mar 27, 2021

Yeah, that's a better idea than what I'm doing. I felt awkward putting it in ReportView, I wanted to put it in App but it didn't support hooks. I didn't realize withS4ACommunication() is only called once from App, makes it a perfect spot. Will change.

@ghost ghost requested review from mesmith027 and randyzwitch as code owners March 29, 2021 17:35
@ghost ghost merged commit 1763f12 into streamlit:feat/anchor-headers Mar 29, 2021
@ghost ghost deleted the anchors-s4a-comm branch March 29, 2021 21:14
ghost pushed a commit that referenced this pull request Apr 6, 2021
* Add anchors to Markdown headers (#2513)

* save progress

* save work

* remove junk code

* fix lint errors

* clean up code a bit

* fix incorrect type

* remove debug code

* fix heading numbers

* make requested changes and clean up HeadingWithAnchor

* only scroll once

* fix issues

* fix jslint

* clean things up

* handle edge case

* missing a void

* fix failing test

* add e2e tests

* add e2e tests

* clean up code by using _.once()

* fix lint

* fix dynamic scrolling

* fix typo

* make requested changes

* run formatting and remove unused import

* remove another unused import

* make requested changes

* add nice link icon to left of headers

* make requested design changes (#2726)

* Fix anchor styling to work with dark mode (#3035)

* fix anchor styling

* Revert "fix anchor styling"

This reverts commit cb5d7fd.

* fix failing cypress tests

* fix styling

* Add S4A communication for anchor headers (#2982)

* add communication with s4a

* fix bug

* save work

* save work

* remove console

* add tests

* remove useless import

* fix failing tests

* Remove Markdown anchors from sidebar (#3059)

* remove markdown anchors from sidebar

* fix test

* add tests

* Fix failing Cypress test for Markdown Anchors (#3077)

* see if this fixes things

* fix things

* fix

* fix scrolling

* add spacer

* save work

* remove unneeded changes
kmcgrady pushed a commit that referenced this pull request Apr 8, 2021
* Add anchors to Markdown headers (#2513)

* save progress

* save work

* remove junk code

* fix lint errors

* clean up code a bit

* fix incorrect type

* remove debug code

* fix heading numbers

* make requested changes and clean up HeadingWithAnchor

* only scroll once

* fix issues

* fix jslint

* clean things up

* handle edge case

* missing a void

* fix failing test

* add e2e tests

* add e2e tests

* clean up code by using _.once()

* fix lint

* fix dynamic scrolling

* fix typo

* make requested changes

* run formatting and remove unused import

* remove another unused import

* make requested changes

* add nice link icon to left of headers

* make requested design changes (#2726)

* Fix anchor styling to work with dark mode (#3035)

* fix anchor styling

* Revert "fix anchor styling"

This reverts commit cb5d7fd.

* fix failing cypress tests

* fix styling

* Add S4A communication for anchor headers (#2982)

* add communication with s4a

* fix bug

* save work

* save work

* remove console

* add tests

* remove useless import

* fix failing tests

* Remove Markdown anchors from sidebar (#3059)

* remove markdown anchors from sidebar

* fix test

* add tests

* Fix failing Cypress test for Markdown Anchors (#3077)

* see if this fixes things

* fix things

* fix

* fix scrolling

* add spacer

* save work

* remove unneeded changes
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants