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

React-Native 0.65 compatibility / Forward-port Accessibility to react-native 0.60 API (#1125) #1126

Closed
wants to merge 1 commit into from
Closed

Conversation

mikehardy
Copy link
Contributor

@mikehardy mikehardy commented Aug 9, 2019

React-Native 0.59 -> 0.60 changed a lot of the AccessibilityInfo API, and this does a straight forward-port of existing functionality (screen reader status detection) to the new API.

Here is the related PR facebook/react-native-website#835

And the doc with new APIs https://facebook.github.io/react-native/docs/accessibilityinfo

This depends on the PR here for types I believe DefinitelyTyped/DefinitelyTyped#37486

There is an opportunity to also expand API coverage to cover the other new accessibility features react-native exposes but if this is desired it might be best to do it separately? Additionally the majority are iOS-specific so if I proposed that change I'd need some guidance.

Fixes #1319

@mikehardy
Copy link
Contributor Author

I don't believe the Microsoft.reactxp CI step will pass until the related DefinitelyTyped PR is resolved

@mikehardy
Copy link
Contributor Author

Incidentally, how are people using RXPTest during this RN60 transition? Should I port it to RN60? Has someone already done that? I want to run through this feature there but I don't want to duplicate effort

this._updateScreenReaderStatus(isEnabled);
});

// Fetch initial state.
RN.AccessibilityInfo.fetch().then(isEnabled => {
if (!initialStateChanged) {
RN.AccessibilityInfo.isScreenReaderEnabled().then(isEnabled => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will crash on non-0.60 versions of RN - fetch currently points at isScreenReaderEnabled - we should probable leave it like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is true, I propose this in the context of a reactxp 2.0 release which will necessarily (I think?) be a breaking change release that is only compatible with >= RN0.60

If I am wrong in that, then I agree with leaving it, but if it cuts off <RN60 then might as well move now? (also assuming my DefinitelyTyped changes are accepted)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reconsidering - I just read through the code (previously I just worked off the docs which make no mention of fetch continuing to exist) and both the old fetch() API call and the "change" event name do exist (thanks for that clue), as such I think two things now:

  1. this is not blocking reactxp compatibility for RN60 at all, so there is no pressure here, we can get it right (as in, cover the full change)
  2. I should update my PR to DefinitelyTyped such that it contains the deprecated functions still (I will do this)

I still think it's not vital to cover RN<0.60 for reactxp@^2 but that is only because of the assumption reactxp@^2 will have incompatible changes in other areas.

That's worth considering + verifying because it would instruct when to land this PR - either immediately when it's in good shape or later when RN0.60 was a reasonable lower-bound

Either way, thanks for the review - it's will directly improve my DefinitelyTyped PR since I missed that the fetch API existed still

Copy link
Collaborator

Choose a reason for hiding this comment

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

Last I chatted with Eric, he wanted to keep the RN compatibility backwards compatible for ~1yr of releases where feasible. Currently there's nothing in 0.60 that constitutes a full breaking change to reactxp, so ideally we'd leave this with the fetch implementation. Is there anything added to new implementation besides the name change?

Copy link
Contributor Author

@mikehardy mikehardy Aug 30, 2019

Choose a reason for hiding this comment

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

Ok - I prefer to be backwards-compatible (aka user friendly) when possible so that works for me. I had a misunderstanding about reactxp@^2 then, and good that it's corrected.

There is more to the API change, there are new features exposed - check the @types diff here https://github.com/DefinitelyTyped/DefinitelyTyped/pull/37745/files

I am not sure the best way to do it but I think it would be cool to expose all the Accessibility getters/events if possible so the plumbing is there for people focused on making accessible apps.

My hesitation is that it was 2 item (screen reader + announce) but now there are 8 items, and of those: 7 work on iOS (all but high contrast), 2 work on Android (screen reader + announce), 3 work on windows (screen reader + announce, and high contrast), then for web it looks like announce only? It is very divergent. But I think the implementation path would be plumb the types through the common then native-common Accessibility with defaults to false similar to high-contrast, and override in iOS where they have the extra features? Then get those in a backwards-compatible way in iOS implementation?

If there's no appetite for fully covering the API then just as a breaking name change I think this is pointless and we should just wait for July 2020 (~1year) then do it. But at least the typings are ready ;-)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Typically if there's new APIs available in RN that we want to expose, we check if the function exists before calling, if it doesn't, return a sensible default value. This allows us to still provide back-compat while exposing features to consumers of newer RN. This is inline with your suggestion for exposing the new iOS functionality but adds a little more protection.
@erictraut - do you have strong opinions about exposing new RN accessibility features that may not be implemented on all RN platforms? My other thought is that this could be exposed as a separate reactxp extension until such a time where everything is supported in a consistent manner

@mikehardy
Copy link
Contributor Author

still waiting on the related PR that provides the types, FWIW - DefinitelyTyped/DefinitelyTyped#37745

@mikehardy
Copy link
Contributor Author

My @types/react-native PR with the new Accessibility API landed, so this should be unblocked now.
I have tested it locally, and it seems good.
I rebased and added a commit that upgrades the @types/react-native dependency to the required upstream version and hopefully CI completes successfully this time

@mikehardy
Copy link
Contributor Author

@berickson1 this is ready for review again I think? Pending resolution on your requests earlier it may be good to go - if not I'll standby to shape it. Thanks!

@fbartho
Copy link
Contributor

fbartho commented Mar 7, 2020

Yesterday on 0.62, I ran into the need for this PR. (#1187) — we are leapfrogging from 0.59 to RN 0.62 which is at RC3

The fetch method wasn’t present (at runtime, at least under jest), so we have to do something. Either detect the new methods and use that, and fallback to fetch for older RN?

I’d like to raise the priority on this fix, as April 30th Apple is requiring iOS 13 SDK, which more or less requires Xcode 11, and 0.60, 0.61, and 0.62 all had lots of changes to improve compatibility with Xcode 11.

I’m thrilled that this PR exists @mikehardy! Thanks!

@fbartho
Copy link
Contributor

fbartho commented Mar 7, 2020

Looking at the comments, I think the sticking point is that we prefer backwards compatibility to as far back as we can. I think where we’re unclear is exactly what strategy needs to be applied here to either get this PR in alignment, or to make a new PR? Do @berickson1, @erictraut, or @mikehardy have a feeling of what kind of PR would be accepted here?

I and a colleague have some time to contribute here, as we would like our release to go into testing in the next two weeks. For my purposes, we weren’t directly using this part of the Accessibility api in our app — yet. Come August, I believe we’ll start to want access to RN’s newly added APIs.

Please let me how I can help move us forwards, thanks!

@mikehardy
Copy link
Contributor Author

Just a note that .62 is on RC5 now and indications are that it's down to "this might be it..." status, as in it's about to go stable / general release literally any day. I also stand ready to make sure this works.

It should be noted that react-native 0.61 does work just fine with Xcode 11 / iOS13, I've been using it for quite some time. Although projects may have different edge cases

Finally I will say that this PR is usable via patch-package once you patch it in to node_modules manually as long as you call the reactxp build in postinstall after patch-package to get the change in. I've done that with other patches in the past on reactxp

@fbartho
Copy link
Contributor

fbartho commented Jul 22, 2020

@mikehardy -- we're on they've reached RN 0.63.2 now, so… maybe we should figure out what it takes to get this merged :P

@mikehardy
Copy link
Contributor Author

@fbartho I think this comment from the in-line review is the most prescriptive #1126 (comment) for exposing new APIs or re-shaping this if needed

@fbartho fbartho added this to the 2.1.0 milestone Aug 6, 2020
@fbartho
Copy link
Contributor

fbartho commented Aug 6, 2020

@mikehardy -- would you mind resolving the package.json conflicts?

Additionally let's figure out what remaining action items there are to get this PR merged & what other PRs/Features need to fast-follow!

@mikehardy
Copy link
Contributor Author

Sure thing - I'll put this in my list in the high priority section but that's still an ETA of a day or three

@fbartho
Copy link
Contributor

fbartho commented Aug 6, 2020

Not at all that urgent from my side / I have plenty of competing challenges. I've tentatively drawn a line in the sand to have a release ready by September 1st -- but that's just a date to help focus my efforts.

Over the next two weeks so, I want to do a dive through all the backlog of Issues, and try to build a Roadmap of some kind + respond to all open tickets, and/or close any dead ones.

@mikehardy
Copy link
Contributor Author

perfect, I work the same way (deadlines to focus, but it's open source after all) and with full sweeps when assuming maintainership of something. I had good luck with installing the welcome bot (not the default github first issue / first PR bot as PRs have a permission issue from forks) and the "stale bot" on my biggest maintained repo for what it's worth:

welcome bot: ankidroid/Anki-Android@5e0086e

stale bot: https://github.com/ankidroid/Anki-Android/blob/master/.github/workflows/stale.yml

@mikehardy
Copy link
Contributor Author

@fbartho rebased + re-pushed

@mikehardy
Copy link
Contributor Author

Last I chatted with Eric, he wanted to keep the RN compatibility backwards compatible for ~1yr of releases where feasible. Currently there's nothing in 0.60 that constitutes a full breaking change to reactxp, so ideally we'd leave this with the fetch implementation. Is there anything added to new implementation besides the name change?

It's been more than a year, and react-native 0.65 just dropped AccessibilityInfo.fetch so reactxp is officially not working with current react-native until this is merged

@mikehardy
Copy link
Contributor Author

Here's the patch-package format patch if anyone else is trying to make all this stuff work...

reactxp+2.0.0.patch.zip

@fbartho / @berickson1 would be great to see a release with this - everything appears to work on RN65 after this patch.

@mikehardy mikehardy changed the title Forward-port Accessibility to react-native 0.60 API (#1125) React-Native 0.65 compatibility / Forward-port Accessibility to react-native 0.60 API (#1125) Aug 23, 2021
@mikehardy
Copy link
Contributor Author

So, a couple years after originally posting this, and a few months after posting that it was a hard breaking change in react-native compatibility, it's pretty obvious this package is dead.

It's important to recognize that and heed the message of the inactivity.

years after both projects were just beginning, it's clear react-native-web has won the community mindshare here.

I've de-integrated reactxp and ported to react-native-web. Works pretty well these days, and not a bad path forward.

I'm closing this, cheers all!

@mikehardy mikehardy closed this Nov 26, 2021
@mikehardy mikehardy deleted the rn60-accessbility-break branch November 26, 2021 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants