Skip to content

Commit

Permalink
fix: hide OverKeyboardView on app reload (#638)
Browse files Browse the repository at this point in the history
## 📜 Description

Hide `OverKeyboardView` when app gets reload from Dev menu.

## 💡 Motivation and Context

I tested Android and iOS Fabric and didn't notice that issue. For me it
seems like it's specific to iOS paper architecture. Initially I thought
that it's because of memory leaks and that component can not be
unmounted - but I haunted memory leaks and XCode profiler didn't show up
any memory leaks 🤷‍♂️ (I also removed big parts of the code but still
could see "zombie" views).

To fix the problem I decided to add listener for
`RCTJavaScriptWillStartLoadingNotification` event and call `hide`. I
tested and it works well, so let's keep this code for now 😊

Closes
#637

## 📢 Changelog

### iOS

- add `RCTJavaScriptWillStartLoadingNotification` listener in
`OverKeyboardView` constructor with `hide` selector;
- clear listener in `dealloc`;

## 🤔 How Has This Been Tested?

Tested manually on iPhone 15 Pro.

## 📸 Screenshots (if appropriate):

|Before|After|
|-------|-----|
|<video
src="https://github.com/user-attachments/assets/c069277a-74b4-4b4a-91ad-12a852f89abb">|<video
src="https://github.com/user-attachments/assets/e94240bf-ddac-4e97-97ab-faa5f262c5e1">|

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
  • Loading branch information
kirillzyusko authored Oct 16, 2024
1 parent d1df467 commit 5053914
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ios/views/OverKeyboardViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,19 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
_touchHandler = [[RCTTouchHandler alloc] initWithBridge:bridge];
_contentView = [[UIView alloc] initWithFrame:CGRectZero];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(hide)
name:RCTJavaScriptWillStartLoadingNotification
object:nil];
return self;
}
#endif

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

// MARK: lifecycle methods
- (void)didMoveToSuperview
{
Expand Down

0 comments on commit 5053914

Please sign in to comment.