Code Monkey home page Code Monkey logo

Comments (7)

AdrianFahrbach avatar AdrianFahrbach commented on June 2, 2024 1

It also looks like the focus ring is the only clickable area of the input fields. In this video the input fields are transformed down by 40.

screenshot.mp4

We override drawFocusRingMask so we can support corner radius, etc.

In my case the focus ring does not follow the border radius of the input field. Increasing the border radius makes this a lot more visible:
screenshot 2024-02-26 at 23 28 52@2x

Is this intentional or should the focus ring have the same border radius as well?
Second question: Can I maybe help you by testing your theory by removing some lines in the node_modules?

from react-native-macos.

AdrianFahrbach avatar AdrianFahrbach commented on June 2, 2024

I got the same issue!

In my case I got a drawer element with an input that gets moved out of the screen. See here:

screenshot.2024-02-03.at.16.41.02.mp4

The solution in my case is to blur the input field before moving it. This only works with multiline input fields though, so I will make the single line input a multiline field. I also already tried setting the multiline prop right before blurring the input, but react-native absolutely does not like that and throws an error.

from react-native-macos.

Saadnajmi avatar Saadnajmi commented on June 2, 2024

I have an idea of why this happens, not sure it'll fix it.

We override drawFocusRingMask so we can support corner radius, etc. Perhaps we also need to account for translation there? Because it's mask (I.E: the thing you put on top of a rect, not where the rect is) I'm not sure if that's the right path forward, but maybe a shot?

https://github.com/search?q=repo%3Amicrosoft%2Freact-native-macos%20drawFocusRing&type=code

from react-native-macos.

Saadnajmi avatar Saadnajmi commented on June 2, 2024

@AdrianFahrbach
Oof, yes both of examples look wrong to me.
You should be able to just make local edits and build, yeah. I'm not sure what local edits per say, but stuff around drawFocusRingMask or any of these overrides to start: https://developer.apple.com/documentation/appkit/nsview/appearance#1662106

Also, if you replace the TextInput with a normal View, do you still repro? That would tell me it's TextInput specific.

from react-native-macos.

AdrianFahrbach avatar AdrianFahrbach commented on June 2, 2024

The focus is rounded on a regular view, it suffers from the same transform problem though:

screenshot.00.27.23.mp4

I did try removing the following from react-native-macos/React/Views/RCTView.m, but I didn't get any focus border at all then.

#pragma mark Focus ring

- (CGRect)focusRingMaskBounds
{
  return self.bounds;
}

- (void)drawFocusRingMask
{
  if ([self enableFocusRing]) {
    CGContextRef context = NSGraphicsContext.currentContext.CGContext;
    RCTCornerInsets cornerInsets = RCTGetCornerInsets(self.cornerRadii, NSEdgeInsetsZero);
    CGPathRef path = RCTPathCreateWithRoundedRect(self.bounds, cornerInsets, NULL);

    CGContextAddPath(context, path);
    CGContextFillPath(context);
    CGPathRelease(path);
  }
}

from react-native-macos.

Saadnajmi avatar Saadnajmi commented on June 2, 2024

We will probably fix #2038 before this one to see if they are related

from react-native-macos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.