-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat(positionning): open popperOptions api #4323
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4323 +/- ##
==========================================
+ Coverage 89.11% 89.15% +0.04%
==========================================
Files 113 113
Lines 3693 3708 +15
Branches 693 693
==========================================
+ Hits 3291 3306 +15
Misses 357 357
Partials 45 45
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
0933db2
to
aa4ac72
Compare
8955c79
to
944f9fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, left some comments!
@@ -17,5 +18,6 @@ export class NgbInputDatepickerConfig extends NgbDatepickerConfig { | |||
container: null | 'body'; | |||
positionTarget: string | HTMLElement; | |||
placement: PlacementArray = ['bottom-start', 'bottom-end', 'top-start', 'top-end']; | |||
popperOptions: (options: Partial<Options>) => Partial<Options>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should initialize directly with function, not undefined?
src/datepicker/datepicker-input.ts
Outdated
@@ -289,6 +298,7 @@ export class NgbInputDatepicker implements OnChanges, | |||
@Inject(DOCUMENT) private _document: any, private _changeDetector: ChangeDetectorRef, | |||
config: NgbInputDatepickerConfig) { | |||
['autoClose', 'container', 'positionTarget', 'placement'].forEach(input => this[input] = config[input]); | |||
this.popperOptions = config.popperOptions || ((options: Partial<Options>) => options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we initialize directly in config, we should avoid having this
src/datepicker/datepicker-input.ts
Outdated
@@ -394,7 +404,9 @@ export class NgbInputDatepicker implements OnChanges, | |||
targetElement: this._cRef.location.nativeElement, | |||
placement: this.placement, | |||
appendToBody: this.container === 'body', | |||
updatePopperOptions: addPopperOffset([0, 2]) | |||
updatePopperOptions: (options) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: arrow function?
const popover = fixture.debugElement.query(By.directive(NgbPopover)).injector.get(NgbPopover); | ||
|
||
const spy = createSpy(); | ||
popover.popperOptions = (options: Partial<Options>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should explain how to use it more clearly in docs:
- is the initial config readonly or can be modified?
- should the user clone it?
- will initial config be discarded and ignored?
Thanks for your review and comments, @maxokorokov ! I've changed the code accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Hello guys. Could you please suggest how do I proceed to get it working in my project ? The fix is not published yet on npm, right ? So, shall I use packag directly from github ? When are you gonna publish this version on npm ? |
First draft about how to give access to the popper options.