Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kind of type math-input #415

Merged
merged 3 commits into from
Mar 20, 2023
Merged

kind of type math-input #415

merged 3 commits into from
Mar 20, 2023

Conversation

handeyeco
Copy link
Contributor

@handeyeco handeyeco commented Mar 15, 2023

Summary:

Just a very quick pass to get some Flow typing in math-input. I would happily continue, but I'm also supposed to be shipping updates to users too.

Issue: LC-618

Test plan:

  • Nothing should change for users, just new types

@handeyeco handeyeco self-assigned this Mar 15, 2023
@changeset-bot
Copy link

changeset-bot bot commented Mar 15, 2023

🦋 Changeset detected

Latest commit: d7ce807

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@khan-actions-bot khan-actions-bot requested a review from a team March 15, 2023 21:48
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Mar 15, 2023

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/cuddly-kings-repair.md, packages/math-input/package.json, packages/math-input/src/fake-react-native-web/view.js, packages/math-input/src/components/input/cursor-handle.js, packages/math-input/src/components/input/math-input.js

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 15, 2023

Size Change: +233 B (0%)

Total Size: 635 kB

Filename Size Change
packages/math-input/dist/es/index.js 60.3 kB +233 B (0%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 38.4 kB
packages/kmath/dist/es/index.js 4.18 kB
packages/perseus-editor/dist/es/index.js 112 kB
packages/perseus-error/dist/es/index.js 825 B
packages/perseus-linter/dist/es/index.js 18.6 kB
packages/perseus/dist/es/index.js 385 kB
packages/pure-markdown/dist/es/index.js 3.74 kB
packages/simple-markdown/dist/es/index.js 12.9 kB

compressed-size-action

@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Merging #415 (d7ce807) into main (f9b69cb) will increase coverage by 0.48%.
The diff coverage is 82.83%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #415      +/-   ##
==========================================
+ Coverage   65.49%   65.97%   +0.48%     
==========================================
  Files         481      487       +6     
  Lines      103927   107131    +3204     
  Branches     5620     7376    +1756     
==========================================
+ Hits        68064    70685    +2621     
- Misses      35863    36446     +583     
Impacted Files Coverage Δ
...ages/math-input/src/components/input/math-input.js 46.40% <78.70%> (+1.27%) ⬆️
...s/math-input/src/components/input/cursor-handle.js 34.72% <100.00%> (+3.33%) ⬆️
...kages/math-input/src/fake-react-native-web/view.js 100.00% <100.00%> (ø)

... and 38 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f9b69cb...d7ce807. Read the comment docs.

Copy link
Collaborator

@jeremywiebe jeremywiebe left a comment

Choose a reason for hiding this comment

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

Little by little. 💪

@@ -239,15 +285,15 @@ class MathInput extends React.Component {
};

/** Gets and cache they bounds of the keypadElement */
_getKeypadBounds = () => {
_getKeypadBounds: () => $FlowFixMe = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think all these things dealing with bounds originate from a call to getBoundingClientRect() which is typed as returning a DOMRect. Could we use that in this file?

Copy link
Contributor Author

@handeyeco handeyeco Mar 16, 2023

Choose a reason for hiding this comment

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

I couldn't get this to work and I don't want to linger too long on this. I was able to add _keypadBounds: ?ClientRect; but when I used ClientRect or ?ClientRect as the return value here errors started to spread.

I'm sure it's fixable, but I think I would need to add logic/checks which I'm trying to avoid in this PR.

packages/math-input/src/components/input/math-input.js Outdated Show resolved Hide resolved
packages/math-input/src/components/input/math-input.js Outdated Show resolved Hide resolved
@@ -651,7 +630,7 @@ class MathInput extends React.Component<Props, State> {
}
};

handleTouchEnd: ($FlowFixMe) => void = (e) => {
handleTouchEnd: (SyntheticTouchEvent<HTMLDivElement>) => void = (e) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The other touch handles use HTMLSpanElement. Should these be the same? If so, I wonder if we should declare a type alias at the top of the file that represents the element type. Ideally I'd love to type this as the result of the render() call, but I don't think it's easy/possible to "extract" that type using Flow utility types.

At a min let's just make sure we have the right DOM element type across all the event registrations.

Given that we don't refer to the target in many of these, I wonder if we can just do SyntheticTouchEvent<*>.. 🤔

Copy link
Contributor Author

@handeyeco handeyeco Mar 16, 2023

Choose a reason for hiding this comment

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

There are two different inputs that are triggering touch events:

  • The View is the container for the math-input and is a div
  • The CursorHandle is another interactive element and is a span

EDIT: when I tried to type the handlers on the window object I found this and decided it wasn't worth the time.

@handeyeco handeyeco merged commit 345673e into main Mar 20, 2023
@handeyeco handeyeco deleted the LC-618/stable-math-input-pass branch March 20, 2023 15:17
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.

3 participants